+ Reply to Thread
Results 1 to 12 of 12

Label checkbox loop

  1. #1
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Label checkbox loop

    Hello

    I am trying to make a checkbox add a number into a label.

    Example:

    If a first checbox is checked, a number 1 will generate in another checkbox. If i uncheck the checkbox the number 1 will go away.

    I figure that ill need a loop to loop through all "checkbox lables" and "number field lables" every time any checkbox is checked/unchecked.

    What im trying so far:

    Please Login or Register  to view this content.
    For now im just testing if its possible to assign multiple labels a number through a loop, but its not working :/

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Label checkbox loop

    Quote Originally Posted by Pavpav View Post
    For now im just testing if its possible to assign multiple labels a number through a loop, but its not working :/
    This is how you can loop through controls based on their base name ("Label_check" and "Label_nr") and a number if that's what you're asking.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    Quote Originally Posted by AlphaFrog View Post
    This is how you can loop through controls based on their base name ("Label_check" and "Label_nr") and a number if that's what you're asking.

    Please Login or Register  to view this content.
    Ty
    That gives me a compile error: Method or data menber not found. If i add dim i as control i get another error: Type mismatch

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Label checkbox loop

    What are the names of your four labels (not their captions)?

    Don't Dim i as Control. It should be Long or Integer.

  5. #5
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    Right clicking them and in properties the names are:

    Label_check1
    Label_check2

    Label_nr1
    Label_nr2

    Please Login or Register  to view this content.
    Clicking on Label_check1 gives me the metod or datamember not found
    Last edited by Pavpav; 09-24-2014 at 11:58 AM.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Label checkbox loop

    Your code works for me.

    These are Labels and not Textbox controls; correct?

  7. #7
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    Yes Label(activeX control)

  8. #8
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Label checkbox loop

    Are these controls on a worksheet or on a UserForm?

    The previous code worked for controls on a userform.

    This works for ActiveX controls on a worksheet. Change the sheet reference to suit.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 09-24-2014 at 02:39 PM.

  9. #9
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    on a worksheet

  10. #10
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Label checkbox loop

    Quote Originally Posted by Pavpav View Post
    on a worksheet
    This works for ActiveX controls on a worksheet. Change the sheet reference to suit.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    thank u very much

  12. #12
    Registered User
    Join Date
    12-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Label checkbox loop

    Now im trying to make a function that will run same code from different labels, but keep getting an error that function or sub are not defined.

    Here is the code im trying to get to work:

    Please Login or Register  to view this content.
    The function is in a class module..
    Any ideas?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Emailing CheckBox Label Value
    By rvinci in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-13-2014, 09:09 PM
  2. status of a do while not loop in a label
    By punna111 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2013, 06:34 PM
  3. Using Loop on CheckBox
    By Jimmyzai in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-06-2012, 01:37 AM
  4. checkbox true/false label
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-04-2005, 12:05 PM
  5. Clicking checkbox Changes the Label Font
    By kcc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2005, 03:06 PM

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