+ Reply to Thread
Results 1 to 9 of 9

make an array of objects, by code?

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    29

    Talking make an array of objects, by code?

    I have the following checkboxes objects, in my form:

    CheckBox1, CheckBox2, CheckBox3, ...

    I want to know what is the value of each one in code.
    Instead of making

    Please Login or Register  to view this content.
    there's a way to check all the checkboxes values with a FOR loop?

    Like:

    Please Login or Register  to view this content.
    Thanks for the help.
    Last edited by mjcordeiro; 01-04-2010 at 04:12 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: make an array of objects, by code?

    Like this
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: make an array of objects, by code?

    Hello mjcordeiro,

    When you say "form" do you mean a VBA UserForm or a worksheet with controls on it?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    01-14-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: make an array of objects, by code?

    Hello Leith Ross,

    I mean VBA UserForm.

    Sincerely,
    Mário

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: make an array of objects, by code?

    Thanks Roy, you taught me a new control!

    A slight adjustment suggestion:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    01-14-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: make an array of objects, by code?

    This is for all the Checkboxes in a Form?
    And if I want to use only some of them, not everyone?
    Because I have other checkboxes inside another Frame.

    Regards,
    Mário

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: make an array of objects, by code?

    Specify the Frame
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-14-2009
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: make an array of objects, by code?

    That helps a lot.

    Thanks royUK.

    Regards,
    Mário

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: make an array of objects, by code?

    You can iterate through the controls in the relevant Frame.

    I learned from RomperStomper that TypeOf(ctl) is CheckBox also returns True for ToggleButton and OptionButton. To verify, create a frame with an option button, a toggle button, and a checkbox, and run the following code:
    Please Login or Register  to view this content.
    So my recommendation is that you use the logic of the second loop, not the first.

    EDIT: I see Roy already covered the first point.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1