View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
John Wilson John Wilson is offline
external usenet poster
 
Posts: 550
Default how do I: launch a macro if two cells do not equak one another?

jason,

The light bulb just went off in my head...sorry.

You need the Worksheet_Change Event.

THis needs to be placed in the worksheet code on the sheet
where you want to capture the change to that sheet. (Right click
on the sheet tab and select "View Code"

Private Sub Worksheet_Change(ByVal Target As Range)
If Worksheets("Sheet1").Range("A2").Value = _
Worksheets("Sheet2").Range("D2").Value Then
MsgBox "They Match"
Else
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "values do not match."
Style = vbOKOnly
Title = "No Match"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
'[lauches new sub routine]
End If
End Sub

John
"jasonsweeney " wrote in
message ...
John,

Lets assume Cell #1 has the value "3" in it.

Lets also assume Cell #2(different sheet) also has the value "3" in
it.

I am concerned when a user changes the value of Cell #1 to anything
other than "3". Thus, when a user click in the cell, and changes the
value of Cell #1 to "1", I want the macro to fire once they press
enter, or click out of the cell. Thus, I assumed Worksheet change was
the correct event. But nothing happens in my code......


---
Message posted from http://www.ExcelForum.com/