At a complete loss! Excel User Form VBA greater than formula not working!

seaottr

Board Regular
Joined
Feb 10, 2010
Messages
60
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi experts out there...I am at a complete loss here! I've spent HOURS trying multiple things to get this BASIC code to work and it still won't work.

I created a user form with 2 text boxes (TextBox1 and TextBox2)

This code IS NOT WORKING for me:

If Me.TextBox1.Value > Me.TextBox2.Value Then
MsgBox "Box 1 is greater than Box 2"
Else
MsgBox "Box 1 is less than Box 2"
End If

It is saying 50 (TextBox1) is greater than 100 (TextBox2)

I've tried using Format(Me.TextBox1.Value, "0") to make sure the values are registered as numbers. All other error checking works using my form element values, including numerical ones.

Please help! I've wasted so much time on this!

Thank you in advance!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try
Code:
If val(Me.TextBox1.Value) > val(Me.TextBox2.Value) Then
 
Upvote 0
FLUFF!!!!! THANK YOU THANK YOU THANK YOU!!!!!!!! You have literally saved me HOURS of wasted time!!!! You are AWESOME!!!!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
I always use something like this:
Not sure there is a different's
Code:
[LEFT][COLOR=#222222][FONT=Tahoma]If CDbl(Me.TextBox1.Value) > CDbl(Me.TextBox2.Value) Then[/FONT][/COLOR][/LEFT]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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