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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,223,958
Messages
6,175,636
Members
452,662
Latest member
Aman1997

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