orcas
04-02-2014, 01:54 AM
Hi there,
Thanks for taking a look. I am having some problems with a worksheet change event. What i want to be able to achieve is run code whenever a cell in a certain column changes but the code should only run if the values in the cell does not equal values in an adjacent cell.
So for instance, run macro if cells [B1] changes, but only if values in cells [B1] <> values in cell [C1]
I will appreciate any help with this.
Thank you.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell_to_test As Range, Cell_changed As Range
Set Cell_changed = Target(1, 1)
Set cell_to_test = Range("H20:H700")
If Not Intersect(Cell_changed, cell_to_test) Is Nothing Then
For i = 1 To 20
If Cells(i, 1) <> Cells(i, 2) Then
LossParameter.LossParam
ActiveSheet.Rows(Target.Row).Interior.Color = vbYellow
End If
Next i
End If
End Sub
Thanks for taking a look. I am having some problems with a worksheet change event. What i want to be able to achieve is run code whenever a cell in a certain column changes but the code should only run if the values in the cell does not equal values in an adjacent cell.
So for instance, run macro if cells [B1] changes, but only if values in cells [B1] <> values in cell [C1]
I will appreciate any help with this.
Thank you.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell_to_test As Range, Cell_changed As Range
Set Cell_changed = Target(1, 1)
Set cell_to_test = Range("H20:H700")
If Not Intersect(Cell_changed, cell_to_test) Is Nothing Then
For i = 1 To 20
If Cells(i, 1) <> Cells(i, 2) Then
LossParameter.LossParam
ActiveSheet.Rows(Target.Row).Interior.Color = vbYellow
End If
Next i
End If
End Sub