Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: launch a macro if two cells do not equak one another?

Its late in the day and I am frustrated not getting this simple
procedure to work:

I need a macro to fire when two cells in two different worksheets do
nto equal one another. Here is my code:

(that does not work....nothing happens at all)
_________
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)

If Worksheets("Sheet1").Range("A2").Value =
Worksheets("Sheet2").Range("D2").Value Then
'
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
_________________

Do I have the wrong event or something?!


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default how do I: launch a macro if two cells do not equak one another?

jason,

That event will only fire if something on the worksheet is changed.
What are you changing on the worksheet?
Is there something else in your code where you could call this
procedure (based on your other thread)??
Within your macro, just check the cells???

There are other events that you might use.
A good listing of them can be found he
http://www.cpearson.com/excel/events.htm

John


"jasonsweeney " wrote in
message ...
Its late in the day and I am frustrated not getting this simple
procedure to work:

I need a macro to fire when two cells in two different worksheets do
nto equal one another. Here is my code:

(that does not work....nothing happens at all)
_________
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)

If Worksheets("Sheet1").Range("A2").Value =
Worksheets("Sheet2").Range("D2").Value Then
'
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
_________________

Do I have the wrong event or something?!


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I: launch a macro if two cells do not equak one another?

John,

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

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

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

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default how do I: launch a macro if two cells do not equak one another?


"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/



  #5   Report Post  
Posted to microsoft.public.excel.programming
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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Launch of Macro Daren Excel Discussion (Misc queries) 1 March 20th 07 08:10 PM
Macro to launch web page hutchie Excel Discussion (Misc queries) 2 May 17th 06 05:30 PM
How do I Launch a Macro on a different sheet Pepe[_2_] Excel Programming 1 January 19th 04 03:15 PM
auto-launch a MACRO? d-cubed Excel Programming 4 December 22nd 03 10:10 PM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"