Multi userform validate for textbox,Checkbox,optionbutton is not empty using class module codes

nileshjadhavshiv

New Member
Joined
Aug 15, 2013
Messages
23
Hi All,

I have design & build 9 to 10 userforms. I need to validate each user-form's Textbox and optionbutton,Checkbox are selected or not if its not selected then code should be stop.

To every userform i have put below code to validate Textbox optionbutton,Checkbox are selected

Private Sub ContLbl_Click()


Dim Cnt As Control, OptBtnVal As Boolean

For Each Cnt In I_EightFrm.Controls

OptBtnVal = Cnt.Name Like "OptionButton*"

If OptBtnVal = True Then
If Cnt.Object = True Then
OB = OB + 1
End If
End If
Next

If OB < 8 Then Call CommonMsg: Exit Sub
If OptionButton84.Value = True And Trim(OthTB.Value) = "" Then Call CommonMsg: Exit Sub
End Sub

My question is i have wrote above code in every userform.is there any shortcut where i can put one time code and it will be working for all userform ( my friend told you can do it with class module but i dont know about class module)

Please help me.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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