PDA

View Full Version : [SOLVED:] AND Cell value A minus Cell value B divided by Cell value A > 0.1



Nico.L
09-24-2021, 01:35 AM
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.

anish.ms
09-24-2021, 02:20 AM
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

Nico.L
09-24-2021, 04:41 AM
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.