Log in

View Full Version : Automatic Subtraction Of Column Values To Adjacent Column



sanjeevi888
08-05-2012, 06:27 PM
Dear Experts,

i want Auto Subtraction between A1:A1000 - B1:B1000 Value apply to C1:C1000 in conditional formatting.
find attachment.

Regards,

Sanjeevi.

Excel Fox
08-05-2012, 07:35 PM
Can you elaborate that please? Are you saying you want to automatically have the column C have the difference of the values in columns A and B?

sanjeevi888
08-05-2012, 08:02 PM
Yes that one..!

Excel Fox
08-05-2012, 09:16 PM
Try this....

Paste this in the sheet code module


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells(1).Column <= 2 Then
With Me
.Range("C2:C" & Application.Max(2, Me.Cells(Rows.Count, 3).End(xlUp).Row)).ClearContents
.Range("C2:C" & Application.Max(.Cells(Rows.Count, 1).End(xlUp).Row, .Cells(Rows.Count, 3).End(xlUp).Row)).Formula = "=A2-B2"
End With
End If

End Sub