initialization of an array????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I need to initialize MyArray (7)
By “Mondayâ€. “Tuesdayâ€,


I tried MyArray = (“Mondayâ€,â€Tuesdayâ€,â€Wednesdayâ€,,)


But it doesn’t work!??
 
Right out of VBA help file.

MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
 
If you can start with Sunday, perhaps...

Sub Demo()
Dim m
m = Application.GetCustomListContents(2)
'Otherwise adjust ...
m = Array(m(2), m(3), m(4), m(5), m(6), m(7), m(1))
End Sub
 
Barb,

Try something like

Dim V(1 To 7) As String ' Best practice to specify both lower and upper
bounds
Dim N As Long
For N = 1 To 7
V(N) = Format(DateSerial(2001, 1, N), "dddd")
Next N
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top