Hello,
Code works for columns C & D, want to make the code work for columns H & I.
Code
- Private Sub WorkSheet_Change(ByVal Target As Range)
- Dim x As Range, y As Long
- If Not Intersect(Target, Columns("C:D")) Is Nothing Then
- Select Case Target.Column
- Case Is = 4
- y = Cells(Rows.Count, 4).End(3).Row
- For Each x In Range(Cells(2, 4), Cells(y, 4))
- If x.Value <> "" And x.Offset(, -1) <> "" Then
- x.Offset(, -2) = x / x.Offset(, -1)
- Else
- x.Offset(, -2) = ""
- End If
- Next x
- Case Is = 3
- y = Cells(Rows.Count, 3).End(3).Row
- For Each x In Range(Cells(2, 3), Cells(y, 3))
- If x.Value <> "" And x.Offset(, 1) <> "" Then
- x.Offset(, -1) = x.Offset(, 1) / x
- Else
- x.Offset(, -1) = ""
- End If
- Next x
- End Select
- End If
- End Sub
thanks
alexsunny