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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,675
Messages
6,126,153
Members
449,294
Latest member
Jitesh_Sharma

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