Consulting

Results 1 to 2 of 2

Thread: UserForm CheckBoxes using variable for name

  1. #1

    UserForm CheckBoxes using variable for name

    I have a form with 80 check boxes with the names assigned as ChkBx1, Chkbx2, Chkbx3 through Chkbx80. I would like to use a variable for the checkbox name to check the value of the check box. Such as:

    [VBA]
    For i = 1 to 80
    CurrentChkBox = ?ChkBx? & i
    CurVal = UserForm.CurrentChkBox
    Next
    [/VBA]

    This will not work since CurrentChkBox is a string and not a control. How can I use a variable as a control name?
    Thanks in advance

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Len

    Use the form's Controls collection.
    [vba]
    For i = 1 To 80
    CurrentChkBox = ?ChkBx? & i
    CurVal = Me.Controls(CurrentChkBox)
    Next
    [/vba]

Posting Permissions

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