Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2012, 03:45 AM
Wries Wries is offline Array argument in macro command Windows XP Array argument in macro command Office 2007
Advanced Beginner
Array argument in macro command
 
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
  #2  
Old 11-17-2012, 08:44 PM
macropod's Avatar
macropod macropod is offline Array argument in macro command Windows 7 64bit Array argument in macro command Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 11-20-2012, 01:08 AM
Wries Wries is offline Array argument in macro command Windows XP Array argument in macro command Office 2007
Advanced Beginner
Array argument in macro command
 
Join Date: Jun 2009
Posts: 40
Wries is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array argument in macro command 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 argument in macro command Array into ComboBox + Macro-Text into ActiveDocument Vivi Word VBA 1 01-27-2010 07:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft