class module for multiple commandbutton click event

Jiyush

New Member
Joined
Apr 5, 2014
Messages
8
I have a user form with 50 rows each containing the controls in order as: Togglebutton101, Togglebutton1, Textbox301, Checkbox1, Textbox1, Combobox1, Combobox101, Checkbox101 and a Commandbutton1.

What I want to do is when I click the commandbutton1 then its preceding controls in its row returned to their default value. I have a code for this but how can I write this for 50 command buttons using class module?

HTML:
Private Sub Cbutton_Click()
dim h as long
for h = 1 to 50
        AB_Paper.Controls("ToggleButton" & h + 100).Value = False
        AB_Paper.Controls("ToggleButton" & h).Value = False
        AB_Paper.Controls("TextBox" & h + 300).Value = 4
        AB_Paper.Controls("CheckBox" & h).Value = False
        AB_Paper.Controls("TextBox" & h).text = ""
        AB_Paper.Controls("ComboBox" & h).Text = "Block"
        AB_Paper.Controls("ComboBox" & h + 100).Text = ""
        AB_Paper.Controls("CheckBox" & h + 100).Value = False
   Next
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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