View Single Post
 
Old 11-14-2012, 03:45 AM
Wries Wries is offline Windows XP Office 2007
Advanced Beginner
 
Join Date: Jun 2009
Posts: 40
Wries is on a distinguished road
Default Array argument in macro command

Hello All,
Is it possible to put an argument from an array directly into command?
I get error "method or data member not found"
Speaking in examples:
i have simplified the values for the purpose of my question
i have userform (CmNm) with check boxes (BoxA, BoxB...)
after clicking on import button i want it to check if boxes in CmNm are ticked and for those that are to do the import
i get error on: CmNm.Box & Element
when i manually write CmNm.BoxA instead (while omitting the For command) it is working, but i have to do each array value manually

Code:
Dim cm, nm As String
Dim hotels
cm = Format(Date, "mmyy")
nm = Format(DateAdd("m", 1, Date), "mmyy")
letters = Array("A", "B", "C")
 
For Each Element In letters
  If CmNm.Box & Element = True Then
    Worksheets("Main").CheckBoxes(Element & cm) = 1
    Worksheets("Main").CheckBoxes(Element & nm) = 1
    Application.Run (Element & "Import")
  End If
Next Element
End Sub
Thank you in advance,
Kind regards,
Wries

Last edited by macropod; 11-17-2012 at 08:26 PM. Reason: Added code tags & formatting
Reply With Quote