SOLVED

VBA help required pls to detect a changed field based and execute a macro

Copper Contributor

I have this in my Macro to detect a change to column O but I now only want it to execute if column A contains an 'x' as well. So if O71 is changed and A71=X then execute the macro. Thanks, Mark

 

'Detect change
If Not Intersect(Target, Range("O1:O1000")) Is Nothing Then
Call UpdateComments(LastRow)
End If

 

 

3 Replies

@Mark_Smith_007 

I'm not sure what exactly I mean, but here is a suggestion for a sample.

 

Detect change
If Range("A71") = "x" Then
If Not Intersect(Target, Range("O1:O1000")) Is Nothing Then
Call UpdateComments(LastRow)
End If

 

 

I would be happy to know if I could help.

 

Nikolino

I know I don't know anything (Socrates)

best response confirmed by Mark_Smith_007 (Copper Contributor)
Solution

@Mark_Smith_007 

For example:

    'Detect change
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("O1:O1000")) Is Nothing Then
        If LCase(Range("A" & Target.Row).Value) = "x" Then
            Call UpdateComments(LastRow)
        End If
    End If

@Hans Vogelaar 

 

 

Dank je, Hans and such a speedy response. It works perfectly.

 

 
 

 

1 best response

Accepted Solutions
best response confirmed by Mark_Smith_007 (Copper Contributor)
Solution

@Mark_Smith_007 

For example:

    'Detect change
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("O1:O1000")) Is Nothing Then
        If LCase(Range("A" & Target.Row).Value) = "x" Then
            Call UpdateComments(LastRow)
        End If
    End If

View solution in original post