VBA comparing signs of rows in 2 columns

zeno

Board Regular
Joined
Feb 16, 2012
Messages
71
Hi,

I am comparing the signs of rows in 2 columns. If the sign is different, I want to multiply the 2nd column by (-1). I have the code below, but it is not working.


Code:
For k = 2 to k
    If sgn(k,"O")<>sgn(k,"P") then range("P"&k)*(-1)
Next k
   End If
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try

If sgn(Cells(k,"O"))<>sgn(Cells(k,"P")) then range("P"&k).Value = Range("P"&k)*-1
 
Upvote 0

Forum statistics

Threads
1,216,776
Messages
6,132,659
Members
449,744
Latest member
kauamarcosms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top