+ Reply to Thread
Results 1 to 3 of 3

Why is this IF code not working.

  1. #1
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Why is this IF code not working.

    I am looking up 3 fields from text boxes on a userform.

    The user enters the following values 0 - 100,000 and 50,000

    In the code it will appear like this;

    Please Login or Register  to view this content.
    However the code does not recognise that 50,000 is smaller than 100,000 and skips that IF statement. (The text boxes have only numbers entered and then formatted to number ) If I remove the comma this issue is still there?
    Is there a way around this?

    If you copy this code into Excel and step through you will see my issue. Thank you

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Why is this IF code not working.

    All your variables are strings, not numbers.

    Try declaring your variables as the types you want - e.g.
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Why is this IF code not working.

    Thanks Olly That's great. I was declaring them incorrectly elsewhere in the code as a variant. It works now. Thank you

+ 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. [SOLVED] This code not working in a Protected Sheet, can any one pls edit this code
    By rajeshn_in in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2016, 01:08 AM
  2. [SOLVED] Pattern Building VBA Code - Working code, would like to use cleaner code
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2015, 03:05 PM
  3. [SOLVED] Vba code working in workbook module but not working from personal.xlb
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-19-2014, 05:47 AM
  4. Replies: 1
    Last Post: 11-13-2013, 10:28 AM
  5. Removing code line stops code working?!?!?
    By adamj1910 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2012, 02:36 PM
  6. [SOLVED] VBA Code (colums to row, autofill) stop working in row 294 when new cable code appear
    By sknifseht in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2012, 05:27 AM
  7. Code for email alerts from excel isn't working, wrong code possibly?
    By jessthorogood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 01:45 AM

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