#1
|
|||
|
|||
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 Kind regards, Wries Last edited by macropod; 11-17-2012 at 08:26 PM. Reason: Added code tags & formatting |
#2
|
||||
|
||||
Hi Wries,
Assuming BoxA, BoxB & BoxC are the control names and not their captions, try: If Me.Controls("Box" & Element).Value = True PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Many thanks macropod. It works perfectly and it will save me a hell lot of a time as that I don't have to put each scenario manually.
Kind regards, Wries |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Complex array formula | andrei | Excel | 9 | 02-03-2012 03:40 AM |
How to capture start and ending Ref. Nos. in an array | KIM SOLIS | Excel | 5 | 09-07-2011 07:43 AM |
Word doc bug when closing from userform command button click macro | Joe Patrick | Word | 1 | 07-05-2011 08:53 PM |
Command Line Argument | xJediDadx | Outlook | 1 | 02-21-2011 03:47 PM |
Array into ComboBox + Macro-Text into ActiveDocument | Vivi | Word VBA | 1 | 01-27-2010 07:03 AM |