What is the syntax to see if a checkbox is checked?

 <userform name>.<checkbox name>.Value
'example
If formHome.chkActiveOnly.Value = True Then
    MsgBox "User has checked the box"
Else
    MsgBox "User has not checked the box"
End If

 

Advertisements

What is the syntax to return the index of the a listbox’s selected value?

#'i' is an integer variable that holds the index
 For i = 0 To <list box name>.ListCount - 1
     If <list box name>.Selected(i) = True Then Exit For
 Next i
#example
 For i = 0 To lstGuestList.ListCount - 1
     If lstGuestList.Selected(i) = True Then Exit For
 Next i

 

What is the syntax to get the date selected for a calendar?

  1. Add a calendar to your userform (for instructions, click here)
  2. As shown in the screenshot below, select your calendar control (default name is always MonthView1)
  3. Select DateClick, as shown circled in red below
  4. A procedure will be auto-generated, containing a parameter called DateClicked
  5. User’s selected date is automatically contained in variable DateClicked

unnamed.png