+ Reply to Thread
Results 1 to 6 of 6

If command not working

  1. #1
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    If command not working

    Hi Guys

    I have two text boxes on a userform both are getting values from somewhere. They both are displaying correct values (that i want those to display) but my formula does not seem to be accepting whatever is displayed.

    Please Login or Register  to view this content.
    e.g. The above IF condition is resulting True even if the value of Bat_Text1 = 75 and value of Tagt_Text1 = 100.

    to ensure CODE and I are seeing the same value, I displayed the values in a message box only if the above condition is true and it is displaying the correct values.

    Please Login or Register  to view this content.
    What am i doing wrong that computer is accepting smaller value as larger value? Any help will be appreciated.

    PS. it is very random. sometimes it would not happen at all and sometimes it keeps happening.
    Life is full of Mysteries, Keep Solving

  2. #2
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: If command not working

    Maybe something like
    Please Login or Register  to view this content.
    Textbox values are text, CLng converts them to numbers

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,462

    Re: If command not working

    A Text Box will contain text so I suspect it is doing a text comparison, not a numeric comparison. Try using CLng or CDouble to get numeric values.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: If command not working

    Thanks guys I will try that right away.

  5. #5
    Registered User
    Join Date
    01-25-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: If command not working

    It seems to be working now. Just because it was happening randomly, i do expect the issue may come back. I will keep this post open until I am fully satisfied. I much appreciate both of your responses.
    Cheers
    Raj

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,462

    Re: If command not working

    I think, if you sort, say 35 and 40, it will be correct but, if you sort 350 and 40, or 3500 and 40, it won't. Simply because 3 is less than 4. That's why it is "random" ... some number pairs will be right, others won't.

+ 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. With ThisWorkbook command not working?
    By bvercher in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2014, 12:09 PM
  2. Command buttons not working
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2014, 06:59 PM
  3. If / Vlookup command not working
    By whitedreamvw in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-26-2013, 06:32 AM
  4. [SOLVED] ChangeLink Command Not Working
    By Dina in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-23-2012, 03:57 PM
  5. Command button is not working by using VBA
    By Webtekr in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2009, 02:22 AM
  6. Command bar controls not working!
    By cheelie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2007, 04:12 PM
  7. command button isn't working
    By Nydia in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-29-2005, 06:06 PM

Tags for this Thread

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