At a complete loss! Excel User Form VBA greater than formula not working!
Results 1 to 5 of 5

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

  1. #1
    New Member
    Join Date
    Feb 2010
    Posts
    32
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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!

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

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

    Try
    Code:
    If val(Me.TextBox1.Value) > val(Me.TextBox2.Value) Then
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    Feb 2010
    Posts
    32
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    FLUFF!!!!! THANK YOU THANK YOU THANK YOU!!!!!!!! You have literally saved me HOURS of wasted time!!!! You are AWESOME!!!!

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,732
    Post Thanks / Like
    Mentioned
    458 Post(s)
    Tagged
    45 Thread(s)

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

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  5. #5
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,730
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

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

    I always use something like this:
    Not sure there is a different's
    Code:
    If CDbl(Me.TextBox1.Value) > CDbl(Me.TextBox2.Value) Then
    Last edited by My Aswer Is This; Jun 18th, 2019 at 02:14 PM.
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please I’m not perfect yet. "Memories are forever"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •