+ Reply to Thread
Results 1 to 2 of 2

Counting CheckBoxes on a Userform

  1. #1
    ExcelMonkey
    Guest

    Counting CheckBoxes on a Userform

    I have a userform. It is increasing in complexity with
    various controls in it. It has:

    1 Text Box
    6 checkboxes
    2 buttons


    Is there a way to count the number of check boxes the form
    has? I know that I can count the number of total controls
    by :

    NumberofControls = Userform1.Controls.Count

    This gives me a value of 9 which includes the text box and
    the two buttons. How do I isolate the checkboxes or any
    other control of my liking.


    Thanks

  2. #2
    Jim May
    Guest

    Re: Counting CheckBoxes on a Userform

    Off Google:

    Try something like the following:

    Dim Ctrl As MSForms.Control
    Dim N As Long
    For Each Ctrl In UserForm1.Controls
    If TypeOf Ctrl Is MSForms.CheckBox Then
    N = N + 1
    End If
    Next Ctrl


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    > I have a userform. It is increasing in complexity with
    > various controls in it. It has:
    >
    > 1 Text Box
    > 6 checkboxes
    > 2 buttons
    >
    >
    > Is there a way to count the number of check boxes the form
    > has? I know that I can count the number of total controls
    > by :
    >
    > NumberofControls = Userform1.Controls.Count
    >
    > This gives me a value of 9 which includes the text box and
    > the two buttons. How do I isolate the checkboxes or any
    > other control of my liking.
    >
    >
    > Thanks




+ 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