Consulting

Results 1 to 3 of 3

Thread: AND Cell value A minus Cell value B divided by Cell value A > 0.1

  1. #1
    VBAX Newbie
    Joined
    Sep 2021
    Posts
    4
    Location

    AND Cell value A minus Cell value B divided by Cell value A > 0.1

    Hi all,

    Could anyone get me closer to what is wrong with this line:

    If Cells(y, z).Value > 5000000 And Cells(y, ReportLastcolumn + z).Value - Cells(y, ReportLastcolumn + z - 1).Value / Cells(y, ReportLastcolumn + z).Value > 0.1 Then
    If I remove the dividing like this:
    If Cells(y, z).Value > 5000000 And Cells(y, ReportLastcolumn + z).Value - Cells(y, ReportLastcolumn + z - 1).Value > 0.1 Then
    then it works. But I need it added in

    I want it to say... AND Cell value A minus Cell value B divided by Cell value A > 0.1

    Any help is much appreciated. Thanks.

  2. #2
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Try using parenthesis

    If Cells(y, z).Value > 5000000 And ((Cells(y, ReportLastcolumn + z).Value - Cells(y, ReportLastcolumn + z - 1).Value) / Cells(y, ReportLastcolumn + z).Value) > 0.1 Then

  3. #3
    VBAX Newbie
    Joined
    Sep 2021
    Posts
    4
    Location
    Thank you, it worked. Ran into another problem that it was dividing by zero and therefore gave an error, but was able to fix it.

Posting Permissions

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