Private Sub testmorestuff()
Dim avarbooks() As Variant
Dim intuserselection As Integer
Const arrayname as string = "avarbooks"
dim whatthe As Variant
avarbooks = Array("Book1", "Book2", "Book3", "Book4")
whatthe = arrayname 'How do I populate whatthe with the array knowing only the name?
intuserselection = 2
MsgBox whatthe(intuserselection)
End Sub
I need to populate whatthe with Array("Book1", "Book2", "Book3", "Book4"), not with "avarbooks." However, the only way to locate Array("Book1", "Book2", "Book3", "Book4") is by using the name "avarbooks" which is contained in a variable. In other words, I have a variable containing the name of an array and I want to operate on said array. How do I set whatthe equal to the array and not the array name?
Is this what you mean
Hope this helps.Sub yourArr() Dim avarbooks, whatthe Dim intuserselection As Integer avarbooks = Array("Book1", "Book2", "Book3", "Book4") whatthe = avarbooks For k = LBound(whatthe) To UBound(whatthe) MsgBox whatthe(k) Next End Sub
Anthony
“Confidence never comes from having all the answers; it comes from being open to all the questions.”
PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks