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

seaottr

New Member
Joined
Feb 10, 2010
Messages
35
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!
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,878
Office Version
365
Platform
Windows
Try
Code:
If val(Me.TextBox1.Value) > val(Me.TextBox2.Value) Then
 

seaottr

New Member
Joined
Feb 10, 2010
Messages
35
FLUFF!!!!! THANK YOU THANK YOU THANK YOU!!!!!!!! You have literally saved me HOURS of wasted time!!!! You are AWESOME!!!!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,878
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,102,731
Messages
5,488,543
Members
407,645
Latest member
suyoggore

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top