Check all, Uncheck all userform command button help pls.

Tubig

Board Regular
Joined
Feb 20, 2003
Messages
66
Is there any way that I can put another commandbutton on my userform to "Check all" and another to "Uncheck all" of the checkboxes visible on the form? :confused:

Any help would be so appreciated! :LOL:

This is my code so far:

Private Sub CheckBox1_Click()

End Sub


Private Sub COMMANDBUTTON1_Click()

If CheckBox1.Value = True Then Range("RANGE_WATER_AND_SEWER").PrintOut Copies:=1
If CheckBox2.Value = True Then Range("RANGE_ELECTRICAL_SERVICE").PrintOut Copies:=1
If CheckBox3.Value = True Then Range("RANGE_EXCAVATION_AND_BACKFILL").PrintOut Copies:=1
If CheckBox4.Value = True Then Range("RANGE_DRILL_PILES").PrintOut Copies:=1
If CheckBox5.Value = True Then Range("RANGE_CRIBBING_MATERIAL").PrintOut Copies:=1
If CheckBox6.Value = True Then Range("RANGE_GRADE_BEAM_MATERIAL").PrintOut Copies:=1
If CheckBox7.Value = True Then Range("RANGE_CRIBBING_LABOUR_WALLS").PrintOut Copies:=1
If CheckBox8.Value = True Then Range("RANGE_CRIBBING_LABOUR_GRADE_BEAM").PrintOut Copies:=1
If CheckBox9.Value = True Then Range("RANGE_WEEPING_TILE").PrintOut Copies:=1
If CheckBox10.Value = True Then Range("RANGE_SUMP_PUMP_LINER").PrintOut Copies:=1
If CheckBox11.Value = True Then Range("RANGE_WINDOW_WELLS").PrintOut Copies:=1
If CheckBox12.Value = True Then Range("RANGE_CONCRETE_FOOTINGS").PrintOut Copies:=1
If CheckBox13.Value = True Then Range("RANGE_CONCRETE_FOUNDATION_WALLS").PrintOut Copies:=1
If CheckBox14.Value = True Then Range("RANGE_CONCRETE_GRADE_BEAM").PrintOut Copies:=1
If CheckBox15.Value = True Then Range("RANGE_CONCRETE_BASEMENT_SLAB").PrintOut Copies:=1
If CheckBox16.Value = True Then Range("RANGE_BSMT_SLAB_CONCRETE_FINISHING").PrintOut Copies:=1
If CheckBox17.Value = True Then Range("RANGE_BSMT_SLAB_FLOOR_PREP").PrintOut Copies:=1
If CheckBox18.Value = True Then Range("RANGE_CONCRETE_PILES").PrintOut Copies:=1
If CheckBox19.Value = True Then Range("RANGE_CONCRETE_GARAGE_SLAB").PrintOut Copies:=1
If CheckBox20.Value = True Then Range("RANGE_CONCRETE_DRIVEWAY_AND_SIDEWALK").PrintOut Copies:=1
If CheckBox21.Value = True Then Range("RANGE_SIDEWALK_BLOCKS_AND_SPLASH_PADS").PrintOut Copies:=1
If CheckBox22.Value = True Then Range("RANGE_GARAGE_SLAB_FINISHING").PrintOut Copies:=1
If CheckBox23.Value = True Then Range("RANGE_GARAGE_SLAB_PREP").PrintOut Copies:=1
If CheckBox24.Value = True Then Range("RANGE_DRIVEWAY_AND_SIDEWALK_LABOUR").PrintOut Copies:=1
If CheckBox25.Value = True Then Range("RANGE_PRECAST_STEPS").PrintOut Copies:=1
If CheckBox26.Value = True Then Range("RANGE_PORCH_AND_DECK_MATERIAL").PrintOut Copies:=1
If CheckBox27.Value = True Then Range("RANGE_FRAMING_MATL._MAIN_FL._EXT").PrintOut Copies:=1
If CheckBox28.Value = True Then Range("RANGE_FRAMING_MATL._MAIN_FL._INT").PrintOut Copies:=1
If CheckBox29.Value = True Then Range("RANGE_FRAMING_MATL._2ND_FL._EXT").PrintOut Copies:=1
If CheckBox30.Value = True Then Range("RANGE_FRAMING_MATL._2ND_FL._INT").PrintOut Copies:=1
If CheckBox31.Value = True Then Range("RANGE_FRAMING_MATL._GARAGE").PrintOut Copies:=1
If CheckBox32.Value = True Then Range("RANGE_FRAMING_MATL._ROOF").PrintOut Copies:=1
If CheckBox33.Value = True Then Range("RANGE_FRAMING_MATL._BSMT._DEVLP.").PrintOut Copies:=1
If CheckBox34.Value = True Then Range("RANGE_FRAMING_LABOUR").PrintOut Copies:=1
If CheckBox35.Value = True Then Range("RANGE_FRAMING_LABOUR_BONUS").PrintOut Copies:=1
If CheckBox36.Value = True Then Range("RANGE_WINDOWS_AND_DOORS").PrintOut Copies:=1
If CheckBox37.Value = True Then Range("RANGE_INTERIOR_STAIRS").PrintOut Copies:=1
If CheckBox38.Value = True Then Range("RANGE_INTERIOR_STAIRS_GARAGE").PrintOut Copies:=1
If CheckBox39.Value = True Then Range("RANGE_ROOF_TRUSS").PrintOut Copies:=1
If CheckBox40.Value = True Then Range("RANGE_FLOOR_JOISTS").PrintOut Copies:=1
If CheckBox41.Value = True Then Range("RANGE_OVERHEAD_GARAGE_DOOR").PrintOut Copies:=1
If CheckBox42.Value = True Then Range("RANGE_PLUMBING_STAGE_1").PrintOut Copies:=1
If CheckBox43.Value = True Then Range("RANGE_PLUMBING_STAGE_2").PrintOut Copies:=1
If CheckBox44.Value = True Then Range("RANGE_ELEC._SERVICE_PNL.").PrintOut Copies:=1
If CheckBox45.Value = True Then Range("RANGE_ELEC._MAIN").PrintOut Copies:=1
If CheckBox46.Value = True Then Range("RANGE_ELEC._FINAL").PrintOut Copies:=1
If CheckBox47.Value = True Then Range("RANGE_VACUUM_SYSTEM").PrintOut Copies:=1
If CheckBox48.Value = True Then Range("RANGE_SECURITY_SYSTEM").PrintOut Copies:=1
If CheckBox49.Value = True Then Range("RANGE_LIGHT_FIXTURES").PrintOut Copies:=1
If CheckBox50.Value = True Then Range("RANGE_HEATING_STAGE_1").PrintOut Copies:=1
If CheckBox51.Value = True Then Range("RANGE_HEATING_STAGE_2").PrintOut Copies:=1
If CheckBox52.Value = True Then Range("RANGE_FIREPLACE_BOX").PrintOut Copies:=1
If CheckBox53.Value = True Then Range("RANGE_FIREPLACE_MANTLE").PrintOut Copies:=1
If CheckBox54.Value = True Then Range("RANGE_FIREPLACE_CERAMICS").PrintOut Copies:=1
If CheckBox55.Value = True Then Range("RANGE_SIDING_SOFFIT_FACIA").PrintOut Copies:=1
If CheckBox56.Value = True Then Range("RANGE_EAVESTROUGH").PrintOut Copies:=1
If CheckBox57.Value = True Then Range("RANGE_ENVELOPE_SEAL").PrintOut Copies:=1
If CheckBox58.Value = True Then Range("RANGE_PARGING").PrintOut Copies:=1
If CheckBox59.Value = True Then Range("RANGE_BRICK_AND_STONE").PrintOut Copies:=1
If CheckBox60.Value = True Then Range("RANGE_ROOF_SHINGLES").PrintOut Copies:=1
If CheckBox61.Value = True Then Range("RANGE_INSULATION_AND_DRYWALL").PrintOut Copies:=1
If CheckBox62.Value = True Then Range("RANGE_INSULATION_AND_DRYWALL_BSMT._DEVLP.").PrintOut Copies:=1
If CheckBox63.Value = True Then Range("RANGE_PAINTING_INTERIOR").PrintOut Copies:=1
If CheckBox64.Value = True Then Range("RANGE_PAINTING_EXTERIOR").PrintOut Copies:=1
If CheckBox65.Value = True Then Range("RANGE_FINISHING_MATL._1").PrintOut Copies:=1
If CheckBox66.Value = True Then Range("RANGE_FINISHING_MATL._2").PrintOut Copies:=1
If CheckBox67.Value = True Then Range("RANGE_FINISHING_MATL._3").PrintOut Copies:=1
If CheckBox68.Value = True Then Range("RANGE_FINISHING_MATL._4").PrintOut Copies:=1
If CheckBox69.Value = True Then Range("RANGE_UNDERLAY_MATL.").PrintOut Copies:=1
If CheckBox70.Value = True Then Range("RANGE_FINISHING_LABOUR_MAIN_AND_UPPER").PrintOut Copies:=1
If CheckBox71.Value = True Then Range("RANGE_FINISHING_LABOUR_LOWER_DEVLP.").PrintOut Copies:=1
If CheckBox72.Value = True Then Range("RANGE_INTERIOR_HAND_RAILING").PrintOut Copies:=1
If CheckBox73.Value = True Then Range("RANGE_TEMP._INT._SAFETY_RAILING").PrintOut Copies:=1
If CheckBox74.Value = True Then Range("RANGE_CABINETS_AND_COUNTERTOPS").PrintOut Copies:=1
If CheckBox75.Value = True Then Range("RANGE_MIRROR_AND_GLASS").PrintOut Copies:=1
If CheckBox76.Value = True Then Range("RANGE_SHOWER_DOORS").PrintOut Copies:=1
If CheckBox77.Value = True Then Range("RANGE_MIRRORED_BIFOLD_DOORS").PrintOut Copies:=1
If CheckBox78.Value = True Then Range("RANGE_CLOSET_SHELVING").PrintOut Copies:=1
If CheckBox79.Value = True Then Range("RANGE_LINO_AND_CARPET").PrintOut Copies:=1
If CheckBox80.Value = True Then Range("RANGE_ULAY_PREP._AND_LABOUR").PrintOut Copies:=1
If CheckBox81.Value = True Then Range("RANGE_APPLIANCES").PrintOut Copies:=1
If CheckBox82.Value = True Then Range("RANGE_LANDSCAPING").PrintOut Copies:=1
If CheckBox83.Value = True Then Range("RANGE_INTERIOR_CLEANING").PrintOut Copies:=1
If CheckBox84.Value = True Then Range("RANGE_FURNACE_CLEANING").PrintOut Copies:=1
If CheckBox85.Value = True Then Range("RANGE_FRAMING_LABOUR_BSMT._DEVLP.").PrintOut Copies:=1



Unload UserForm1


End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()

CheckBox1.Caption = "WATER_AND_SEWER"
CheckBox2.Caption = "ELECTRICAL_SERVICE"
CheckBox3.Caption = "EXCAVATION_AND_BACKFILL"
CheckBox4.Caption = "DRILL_PILES"
CheckBox5.Caption = "CRIBBING_MATERIAL"
CheckBox6.Caption = "GRADE_BEAM_MATERIAL"
CheckBox7.Caption = "CRIBBING_LABOUR_WALLS"
CheckBox8.Caption = "CRIBBING_LABOUR_GRADE_BEAM"
CheckBox9.Caption = "WEEPING_TILE"
CheckBox10.Caption = "SUMP_PUMP_LINER"
CheckBox11.Caption = "WINDOW_WELLS"
CheckBox12.Caption = "CONCRETE_FOOTINGS"
CheckBox13.Caption = "CONCRETE_FOUNDATION_WALLS"
CheckBox14.Caption = "CONCRETE_GRADE_BEAM"
CheckBox15.Caption = "CONCRETE_BASEMENT_SLAB"
CheckBox16.Caption = "BSMT_SLAB_CONCRETE_FINISHING"
CheckBox17.Caption = "BSMT_SLAB_FLOOR_PREP"
CheckBox18.Caption = "CONCRETE_PILES"
CheckBox19.Caption = "CONCRETE_GARAGE_SLAB"
CheckBox20.Caption = "CONCRETE_DRIVEWAY_AND_SIDEWALK"
CheckBox21.Caption = "SIDEWALK_BLOCKS_AND_SPLASH_PADS"
CheckBox22.Caption = "GARAGE_SLAB_FINISHING"
CheckBox23.Caption = "GARAGE_SLAB_PREP"
CheckBox24.Caption = "DRIVEWAY_AND_SIDEWALK_LABOUR"
CheckBox25.Caption = "PRECAST_STEPS"
CheckBox26.Caption = "PORCH_AND_DECK_MATERIAL"
CheckBox27.Caption = "FRAMING_MATL._MAIN_FL._EXT"
CheckBox28.Caption = "FRAMING_MATL._MAIN_FL._INT"
CheckBox29.Caption = "FRAMING_MATL._2ND_FL._EXT"
CheckBox30.Caption = "FRAMING_MATL._2ND_FL._INT"
CheckBox31.Caption = "FRAMING_MATL._GARAGE"
CheckBox32.Caption = "FRAMING_MATL._ROOF"
CheckBox33.Caption = "FRAMING_MATL._BSMT._DEVLP."
CheckBox34.Caption = "FRAMING_LABOUR"
CheckBox35.Caption = "FRAMING_LABOUR_BONUS"
CheckBox36.Caption = "WINDOWS_AND_DOORS"
CheckBox37.Caption = "INTERIOR_STAIRS"
CheckBox38.Caption = "INTERIOR_STAIRS_GARAGE"
CheckBox39.Caption = "ROOF_TRUSS"
CheckBox40.Caption = "FLOOR_JOISTS"
CheckBox41.Caption = "OVERHEAD_GARAGE_DOOR"
CheckBox42.Caption = "PLUMBING_STAGE_1"
CheckBox43.Caption = "PLUMBING_STAGE_2"
CheckBox44.Caption = "ELEC._SERVICE_PNL."
CheckBox45.Caption = "ELEC._MAIN"
CheckBox46.Caption = "ELEC._FINAL"
CheckBox47.Caption = "VACUUM_SYSTEM"
CheckBox48.Caption = "SECURITY_SYSTEM"
CheckBox49.Caption = "LIGHT_FIXTURES"
CheckBox50.Caption = "HEATING_STAGE_1"
CheckBox51.Caption = "HEATING_STAGE_2"
CheckBox52.Caption = "FIREPLACE_BOX"
CheckBox53.Caption = "FIREPLACE_MANTLE"
CheckBox54.Caption = "FIREPLACE_CERAMICS"
CheckBox55.Caption = "SIDING_SOFFIT_FACIA"
CheckBox56.Caption = "EAVESTROUGH"
CheckBox57.Caption = "ENVELOPE_SEAL"
CheckBox58.Caption = "PARGING"
CheckBox59.Caption = "BRICK_AND_STONE"
CheckBox60.Caption = "ROOF_SHINGLES"
CheckBox61.Caption = "INSULATION_AND_DRYWALL"
CheckBox62.Caption = "INSULATION_AND_DRYWALL_BSMT._DEVLP."
CheckBox63.Caption = "PAINTING_INTERIOR"
CheckBox64.Caption = "PAINTING_EXTERIOR"
CheckBox65.Caption = "FINISHING_MATL._1"
CheckBox66.Caption = "FINISHING_MATL._2"
CheckBox67.Caption = "FINISHING_MATL._3"
CheckBox68.Caption = "FINISHING_MATL._4"
CheckBox69.Caption = "UNDERLAY_MATL."
CheckBox70.Caption = "FINISHING_LABOUR_MAIN_AND_UPPER"
CheckBox71.Caption = "FINISHING_LABOUR_LOWER_DEVLP."
CheckBox72.Caption = "INTERIOR_HAND_RAILING"
CheckBox73.Caption = "TEMP._INT._SAFETY_RAILING"
CheckBox74.Caption = "CABINETS_AND_COUNTERTOPS"
CheckBox75.Caption = "MIRROR_AND_GLASS"
CheckBox76.Caption = "SHOWER_DOORS"
CheckBox77.Caption = "MIRRORED_BIFOLD_DOORS"
CheckBox78.Caption = "CLOSET_SHELVING"
CheckBox79.Caption = "LINO_AND_CARPET"
CheckBox80.Caption = "ULAY_PREP._AND_LABOUR"
CheckBox81.Caption = "APPLIANCES"
CheckBox82.Caption = "LANDSCAPING"
CheckBox83.Caption = "INTERIOR_CLEANING"
CheckBox84.Caption = "FURNACE_CLEANING"
CheckBox85.Caption = "FRAMING_LABOUR_BSMT._DEVLP."





End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi

Bit primitive but here goes.

Code:
Private Sub CommandButton1_Click()
'clear all
For i = 0 To UserForm1.Controls.Count - 1
  If Left(Controls(i).Name, 8) = "CheckBox" Then
    Controls(i).Value = False
  End If
Next i
End Sub

Private Sub CommandButton2_Click()
'select all
For i = 0 To UserForm1.Controls.Count - 1
  If Left(Controls(i).Name, 8) = "CheckBox" Then
    Controls(i).Value = True
  End If
Next i

End Sub


Tony
 
Upvote 0
This code will "Check" all checkboxes on your userform:
Code:
Dim Ctrl As Control
    For Each Ctrl In Me.Controls
        If TypeName(Ctrl) = "CheckBox" Then
        Ctrl.Value = True    'False to Uncheck
        End If
    Next Ctrl
Assign this code to your Userform "Check All" button.
 
Upvote 0
Thank you soooooooooo much guys! I have 85 checkboxes on my userform. Lifesavers! :biggrin: :biggrin: :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,598
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top