I am hoping someone can help with the vba code for subtracting one column from another.
I am trying to subtract column "O" from column "C". The result goes in column "S". (S= C-O)
The first row of each column has a name header - so the data starts in row 2.
The overall number of rows vary from time to time so I need to be able to adjust for that.
I tried the flowing but I did not get the formula correct. I am not a code wizard and tried to copy some other examples.
Range("S2").Select
Dim LR As Long, i As Long
LR = Range("S" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("S" & i)
.Value = .Offset(, -16).Value - .Offset(, -4).Value
End With
Next I
Any suggestions or advice would be appreciated.
I am trying to subtract column "O" from column "C". The result goes in column "S". (S= C-O)
The first row of each column has a name header - so the data starts in row 2.
The overall number of rows vary from time to time so I need to be able to adjust for that.
I tried the flowing but I did not get the formula correct. I am not a code wizard and tried to copy some other examples.
Range("S2").Select
Dim LR As Long, i As Long
LR = Range("S" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("S" & i)
.Value = .Offset(, -16).Value - .Offset(, -4).Value
End With
Next I
Any suggestions or advice would be appreciated.