Validation of input from user in a macro

Mark_richardson28

New Member
Joined
Sep 29, 2006
Messages
36
As part of my spreadsheet i need the macro to calculate whether the sum of 6 text boxes = 1. If not i need it to alert the user to check their input. I have tried

Code:
If Me.txttas + Me.txtooh.Value + Me.txtengaged.Value + Me.txtother.Value + Me.txtrecycled.Value + Me.txtclosed.Value <> Me.txtprompts.Value Then
Call BadInput("nocompute"): Exit Sub
End If

But it doesn't seem to like what i have.

Any suggestions?

Many thanks
 
Disregard the last - I tripped over you there.
So it would appear that your procedure was being exitted before it ever got to the lines in question!

ref the last question, I'm sure you can do this easily, just can't remember how. I seem to remember it's just setting one of the properties of the textbox.
Having a look now.......
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Tripping over each other there.
So it's flagging up either way - back to my previous then, the figures can't be what you think. Try the msgbox idea or locals window from my previous and see.
One other thought, you're using Me.... a lot, is the procedure in the right place for this... i.e. are you sure you don't need to make the whole reference to get the numbers you want?
 
Upvote 0
........on the other question, use the userform activate event to select all of the text in the first textbox you want highlighted:
Code:
Private Sub UserForm_Activate()
Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1.Value)
End Sub
............. and the enter event for any others on the same userform in case users tab through them:
Code:
Private Sub TextBox2_Enter()
Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1.Value)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
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