• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

need a short code for user form, textbox

mahaveer

Member
I have 20 textbox on one user form and i have a command button now i want to add a code in command button like this:


If TextBox1.Value = "" Then

MsgBox "You must have to mention actual amount received in the month of Jan", vbInformation, "Amount Received"

Me.TextBox1.SetFocus

Exit Sub

Else

If Not IsNumeric(TextBox1) Then

MsgBox "Only numbers allowed", vbInformation, "Jan"

Me.TextBox1.Value = ""

Me.TextBox1.SetFocus

Exit Sub

End If

End If


But i think i have to write the same code 20 times with minor changes.

Is there any other option?
 
It can be done using a Class module, which is something I am still working on learning myself. =(


Fortunately, there's a similar question out there that I was able to find. Check it out:

http://stackoverflow.com/questions/5940596/excel-vba-userform-execute-sub-when-something-changes
 
Back
Top