+ Reply to Thread
Results 1 to 8 of 8

IF-THEN-ELSE not working properly

  1. #1
    Registered User
    Join Date
    11-02-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    21

    Lightbulb IF-THEN-ELSE not working properly

    Hi, this is my first time posting here. I've been searching for a thread that might be helpful for my current issue but could not find one.
    these are the lines im having issues with:

    Please Login or Register  to view this content.
    My goal is if all-caps variable FNTotQty is QTY then it should run the code above but it it is not the case. It does the opposite. If the actual value of FNTotQty <> QTY, the code will run. This is really weird. Help please.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,316

    Re: IF-THEN-ELSE not working properly

    Have you stepped through the code with F8 to see what's happening?

    Also, try putting a breakpoint on these 2 lines with F9,
    Please Login or Register  to view this content.
    then run the code and see what happens.
    If posting code please use code tags, see here.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    2013 on Win10 (desktop), 2007 on Win10 (notebook)
    Posts
    8,000

    Re: IF-THEN-ELSE not working properly

    Hi, danex,

    to me sounds like maybe additional trailing blanks behind the value that you compare in your workbook:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: IF-THEN-ELSE not working properly

    That is because by saying UCase(FNTotQty) you are changing any value in Range B43 to be uppercase. Example: if the value in B43 is qty then UCase(FNTotQty) will make it QTY. It should already be case specific so just remove the UCase statement. Example

    Please Login or Register  to view this content.
    Last edited by stnkynts; 11-02-2013 at 10:32 AM.

  5. #5
    Registered User
    Join Date
    11-02-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: IF-THEN-ELSE not working properly

    Quote Originally Posted by HaHoBe View Post
    Hi, danex,

    to me sounds like maybe additional trailing blanks behind the value that you compare in your workbook:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    hi holger, i double-checked it. no trailing blanks.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,316

    Re: IF-THEN-ELSE not working properly

    Which worksheet is Cells meant to reference here?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-02-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: IF-THEN-ELSE not working properly

    hi all.

    thanks for the response. I was probably just pretty overwhelmed with all the programming languages i wanted to learn. I realized I was pointing to the wrong worksheet. the ws in Workbooks(wb).Worksheets(ws).Range("B43") should not have been ws.

    By the way, how do I close this thread?

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    2013 on Win10 (desktop), 2007 on Win10 (notebook)
    Posts
    8,000

    Re: IF-THEN-ELSE not working properly

    Hi, danex,

    mark the thread Solved via Thread Tools next to the opening Post for this thread. You canīt close any thread unless you are Mod/Admin in this Forum.

    Ciao,
    Holger

+ 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] IF formula not working properly
    By argentraven in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-04-2013, 01:56 PM
  2. VBA not working properly
    By stevemills04 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2013, 02:56 PM
  3. UDF not working properly
    By demuro1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2008, 04:36 PM
  4. [SOLVED] Why is my tab key not working properly any more in Excel?
    By Steelman46 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2006, 12:25 PM
  5. [SOLVED] CNTRL + END is not working properly
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 07:05 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