SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-2139445%22%20slang%3D%22en-US%22%3EVBA%20help%20required%20pls%20to%20detect%20a%20changed%20field%20based%20and%20execute%20a%20macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139445%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20this%20in%20my%20Macro%20to%20detect%20a%20change%20to%20column%20O%20but%20I%20now%20only%20want%20it%20to%20execute%20if%20column%20A%20contains%20an%20'x'%20as%20well.%20So%20if%20O71%20is%20changed%20and%20A71%3DX%20then%20execute%20the%20macro.%20Thanks%2C%20Mark%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E'Detect%20change%3CBR%20%2F%3EIf%20Not%20Intersect(Target%2C%20Range(%22O1%3AO1000%22))%20Is%20Nothing%20Then%3CBR%20%2F%3ECall%20UpdateComments(LastRow)%3CBR%20%2F%3EEnd%20If%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2139445%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New 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 (New 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.