MrExcel Publishing
Your One Stop for Excel Tips & Solutions

if is a match, then subtract


Posted by Jim on January 10, 2002 12:37 PM

Hello all,

I have 4 columns of numbers B,C,E, and G with
corresponding rows 51 thru 56...so starting with
row 52, if E52 = "matches" E51 then G51 = G51 - G52

If anyone can point me in the right direction it would
be much appreciated.

Jim


Posted by Chris D on January 10, 2002 1:43 PM

I think you might have a circular arguement there.....

"then g51=g51-g52"

G51 can't be equal to itself less something else, excel won't like it and will give you a circular reference

:-(

Posted by Conrade on January 10, 2002 1:47 PM


With a macro :-

Dim cell As Range
Set cell = Range("E52")
While cell.Address <> Range("E57").Address
If cell.Value = cell.Offset(-1, 0) Then
cell.Offset(0, 2).Value = cell.Offset(0, 2) - cell.Offset(-1, 2)
End If
Set cell = cell.Offset(1, 0)
Wend


Posted by Jim on January 10, 2002 2:37 PM