IF Intersect not working correctly

Laavista

Board Regular
Joined
Aug 27, 2009
Messages
79
I need to display a message if a cell is changed. I got this working, but it's also displaying the message when a procedure puts a note in another column.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
For example:<o:p></o:p>
<o:p> </o:p>
A B C<o:p></o:p>
1 123 No <o:p></o:p>
2 489 Yes Notes added via VBA code<o:p></o:p>
3 285 No<o:p></o:p>
<o:p> </o:p>
If A1 is changed to something, e.g., 999, then the message should display, but NOT if a note is added in C2.<o:p></o:p>
<o:p> </o:p>
My code:<o:p></o:p>
Private Sub WORKSHEET_CHANGE(ByVal TARGET As Range)

If Intersect(TARGET, Range("A1:A4000")) Is Nothing Then
Exit Sub
Else
MsgBox ("IF ID WAS CORRECTED... " _
& vbCrLf & vbCrLf & " ==> Update Checklist... "), vbCritical _

End If
End Sub<o:p></o:p>

<o:p> </o:p>
I also tried range("A:A") with no luck.<o:p></o:p>
<o:p> </o:p>
I really appreciate your help!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
There's nothing wrong with what you have so presumably it is firing the message when a multi-columnar range is being altered (ie one that includes A and C cells). In which case you could amend to only fire if single cells are changed:

Code:
Private Sub WORKSHEET_CHANGE(ByVal TARGET As Range)

If Target.Count>1 Then Exit Sub
If Not Intersect(TARGET, Range("A:A")) Is Nothing Then
  MsgBox "IF ID WAS CORRECTED... " _
& vbCrLf & vbCrLf & " ==> Update Checklist... ", vbCritical
End If
End Sub
 
Upvote 0
THANK YOU. I cannot tell you how much this has helped. I really appreciate you taking the time to respond!

:)
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top