+ Reply to Thread
Results 1 to 2 of 2

Userform Objects

  1. #1
    Kaval
    Guest

    Userform Objects

    Can objects on a userform (eg. all labels or all command buttons) be treated
    as a collection?

    I have a userform with a large number of labels and I would like to perform
    a similar operation on each label without naming them one by one in the code.

    Thanks, Kaval

  2. #2
    Norman Jones
    Guest

    Re: Userform Objects

    Hi Kaval,

    Try something like:

    Sub Tester()

    Dim Ctrl As MSForms.Control
    For Each Ctrl In UserForm1.Controls
    If TypeOf Ctrl Is MSForms.Label Then
    'Do something: e.g.:
    MsgBox Ctrl.Caption
    Else
    'Do something else
    End If
    Next Ctrl

    End Sub


    ---
    Regards,
    Norman



    "Kaval" <[email protected]> wrote in message
    news:[email protected]...
    > Can objects on a userform (eg. all labels or all command buttons) be
    > treated
    > as a collection?
    >
    > I have a userform with a large number of labels and I would like to
    > perform
    > a similar operation on each label without naming them one by one in the
    > code.
    >
    > Thanks, Kaval




+ 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