+ Reply to Thread
Results 1 to 6 of 6

Greater than doesn't work when comparing values from two textboxes

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Greater than doesn't work when comparing values from two textboxes

    Hi all,

    I have a tricky situation where for some reason greater than is not working when comparing values between two textboxes. For example, if I write value 9900 in to TxtMuoSaldo and then value 999 to TxtMuoMaara I don't get right outcome. Code below.

    Please Login or Register  to view this content.
    Could there be something wrong with Textbox settings???

    Thank you already in advance,

    Ville

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Greater than doesn't work when comparing values from two textboxes

    You are running the code on the change event, which will run for 9, 9, 0 and 0, put it on the exit then the code will run on the value entered.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Greater than doesn't work when comparing values from two textboxes

    Hi nathansav,

    And thank you for your reply. However, it didn't remove the problem so do you have any other idea??

  4. #4
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Greater than doesn't work when comparing values from two textboxes

    Are there any other solutions for this??

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Greater than doesn't work when comparing values from two textboxes

    Textboxes contain text, not numbers, and 9900 comes before 999 in alphanumeric sequence. Use the Exit event and use CDbl or Val to convert:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    04-24-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: Greater than doesn't work when comparing values from two textboxes

    Woohoo!!

    Thank you romperstromper, that really did the trick!! Super!!

    Cheers,
    Ville

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. SetFocus doesn't work properly on a Userform on ComboBoxes and TextBoxes
    By pimre in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-15-2013, 03:15 PM
  2. [SOLVED] Comparing Two Columns of Emails / EXACT doesn't work
    By SpeakingPeace in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-23-2013, 04:28 PM
  3. Comparing multiple sets of columns for greater values
    By metsfan666 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-09-2012, 08:41 PM
  4. Vlookup doesn't work after cell values are changed
    By Jmenace in forum Excel General
    Replies: 2
    Last Post: 03-12-2010, 03:28 PM
  5. Comparing columns for values greater than each other
    By macaonghus in forum Excel General
    Replies: 5
    Last Post: 04-27-2009, 07:28 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1