Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: IF Condition To Check Whether Absolute Value Is Greater Than Other Absolute Values

  1. #1
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0

    IF Condition To Check Whether Absolute Value Is Greater Than Other Absolute Values

    Hi,

    I'm very new to writing codes and i'm trying to incorporate a Code in my macro

    The logic goes like this - Absolute value of Column N should not be greater than the absolute amount in column M or Column R.

    If the amount is greater, then i need a comment in a column stating "ERROR". If it is equal to or less than, then i need a comment stating "OK"

    I have attached my excel data with the macro that I have created.
    The code that is required is one of the last codes that I require to complete my macro.

    Appreciate your assistance.


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40455&p=313035#p313035
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312889#p312889
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312886#p312886
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312752#p312752
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312734#p312734
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312727#p312727
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312724#p312724
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40374&p=312535#p312535
    https://www.eileenslounge.com/viewtopic.php?p=312533#p312533
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40373&p=312499#p312499
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg. 9xhyRrsUUOM9xpn-GDkL3o
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=UgzlC5LBazG6SMDP4nl4AaABAg
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=UgzlC5LBazG6SMDP4nl4AaABAg. 9zYoeePv8sZ9zYqog9KZ5B
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg. 9xhyRrsUUOM9zYlZPKdOpm
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Attached Files Attached Files
    Last edited by DocAElstein; 03-01-2024 at 03:02 PM.

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    You don't need a greater than or lesser than conditional VBA. You can just build a formula using VBA instead, and use it in column W (or the last empty column)

    Code:
    Sub GetErrorOK()
    
        With Worksheets("ccm_dispute_results")
            .Range("W2:W" & .Cells(.Rows.Count, 1).End(xlUp).Row).Formula = "=IF(OR(ABS(N2)>ABS(R2),ABS(N2)>ABS(M2)),""Error"",""OK"")"
        End With
        
    End Sub
    Anyway, since your query was Excel related, moving this thread to the Excel Help section. Also, please try to give a more meaningful and concise thread title, so that other people looking for similar solutions will be able to get search results from search engines. This can only happen if the thread title used is apt.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0
    Hi, thanks for the code and renaming the Thread title appropriately.
    But why would it throw an error for rows 33,36,37,39 where the numbers match for column N and Column M?

  4. #4
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0
    I guess it is due to column R being blank. But there will be many times where my column R will be blank. i.e. Zero amount.

  5. #5
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    What would you want to do in that case?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  6. #6
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0
    I would still want the same result but keeping in mind that R column would be blank at some ocassions. Would that be possible?

  7. #7
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    OK, so if R is empty (actually, your sheet is showing zeroes, not blanks), then you want the formula to ignore that condition, right? And what about column M? What if that is also empty?
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  8. #8
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0
    Yes, i want the formula to ignore that condition for column R. Column M wont have Zeroes.

  9. #9
    Member
    Join Date
    Jul 2013
    Posts
    31
    Rep Power
    0
    But i can sometimes have column N Blank (Zeroes).

  10. #10
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    so in the above code just use
    Code:
    "=IF(OR(AND(ABS(R2)<>0,ABS(N2)>ABS(R2)),ABS(N2)>ABS(M2)),""Error"",""OK"")"
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Absolute Calender Program!
    By Preeti Verma in forum Excel Help
    Replies: 1
    Last Post: 11-06-2012, 01:19 PM
  2. Macro to check values based on certain text
    By Howardc in forum Excel Help
    Replies: 25
    Last Post: 11-05-2012, 09:03 PM
  3. Formula Based On Condition
    By Aryan063007 in forum Excel Help
    Replies: 4
    Last Post: 10-09-2012, 10:37 AM
  4. Loop and Check For Values In Entire Column in Excel
    By Jeff5019 in forum Excel Help
    Replies: 3
    Last Post: 05-01-2012, 10:34 PM
  5. Calculation with different condition in a cell
    By LalitPandey87 in forum Excel Help
    Replies: 5
    Last Post: 04-04-2012, 08:38 AM

Tags for this Thread

Posting Permissions

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