ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming»
  • Programming Languages

Creating A Userform with Checkboxes in VBA

Updated on February 2, 2013
  1. Open the Visual Basic Editor
  2. Create a UserForm (Right Click on Micrsoft Excel Object, select insert>userform)
  3. Show the Control Toolbox (View>Toolbox)
  4. Click the Checkbox on the toolbox(Drag to appropriate size and location on Form)
  5. Click the Commandbox on the (Drag to appropriate size and location on form)
  6. Create conditional code based on checkbox value. If checked value=True, Unchecker value=false
  7. Go back to the form double click on command button and call the conditional macro.
  8. Back in the main module create a new macro to show the form.

Code for Userform

Private Sub CommandButton1_Click()
Call onexecute
End Sub

Sample Conditional Code for Checkbox

Sub ShowUserForm()
End Sub

Sub onexecute()
If UserForm1.CheckBox1.Value = True Then
	Call macro1
End If
If UserForm1.CheckBox2.Value = True Then
	Call macro2
End If
If UserForm1.CheckBox3.Value = True Then
	Call macro3
End If
End Sub

Sub macro1()
MsgBox ("Checkbox 1 is checked.")
End Sub

Sub macro2()
MsgBox ("Checkbox 2 is checked.")
End Sub

Sub macro3()
MsgBox ("Checkbox 3 is checked.")
End Sub

Video Tutorial


    0 of 8192 characters used
    Post Comment

    • profile image

      Sherell Spire 3 years ago

      醉美张北网(是张北最大最专业的二手交易发布网站,张北二手货频道是最大的网上张北二手市场,跳蚤市场提供免费的张北二手信息发布,是闲置物品旧货出售求购交换,进行二手物品交易的最佳选择 ,网站发布主要有 xboter 2014

    • profile image

      Eugene Seber 3 years ago

      Joyful to become here