Toon posts:

[VBA] Expected Array?

Pagina: 1
Acties:
  • 52 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik heb onderstaande code geschreven, nu krijg ik op regel 8 steeds een melding: Expected Array. Wat doe ik fout? :( Het heeft wel gewerkt maar er ging wat mis een keer bij het saven. Ik ben een beginner op het gebied van VBA en programmeren. Dus ik weet niet goed hoe dit op te lossen. Wie helpt me?

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Sub LoopSheet1()
    Dim Sht1x       As Integer
    Dim WeekArray   As Integer
    Dim x           As Integer
    Dim w           As Integer
    
    For x = 1 To 5
        WeekArray(x) = 12 * x - 7
    Next x
    Sht1x = 2
        
    Sheet2.Cells(1, 1) = "kamer: " & Sheet1.Cells(Sht1x, 2).Value
    Sheet2.Cells(1, 9) = "week " & WeekNumber(Sheet1.Cells(Sht1x, 2).Value)
    
    Do While Sheet1.Cells(Sht1x, 1) <> ""
        w = WeekArray(Weekday(Sheet1.Cells(Sheet1x, 2), vbMonday))
        Sheet2.Cells(w, 1) = Sheet1.Cells(Sht1x, 2)
        Sheet2.Cells(w, 2) = Sheet1.Cells(Sht1x, 3)
        Sheet2.Cells(w, 3) = Sheet1.Cells(Sht1x, 4)
        Sheet2.Cells(w, 4) = Sheet1.Cells(Sht1x, 5) & " " & Sheet1.Cells(Sht1x, 6)
        Sheet2.Cells(w, 5) = Sheet1.Cells(Sht1x, 7)
        If Sheet1.Cells(Sht1x, 9) = "" Then
            If Sheet1.Cells(Sht1x, 12) = "Nee" Then
                'tekst
            Else
                'tekst
            End If
        Else
            If Sheet1.Cells(Sht1x, 12) = "Nee" Then
                'tekst
            Else
                'tekst
            End If
        End If
    Loop
End Sub
Public Function WeekNumber(dDate As Date) As Integer
    WeekNumber = Format(dDate, "ww", vbMonday, vbFirstFourDays)
End Function
Public Function FirstDayInWeek(dDate) As Date
    FirstDayInWeek = dDate - Weekday(dDate, vbMonday) + 1
End Function

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

Je hebt Weekarray gedimd als een integer, niet als een array. [google=vba array tutorial] moet je wel verder helpen, hier is meer dan genoeg over te vinden. :)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


Dit topic is gesloten.