#1   Report Post  
James Hamilton
 
Posts: n/a
Default Assign Macro

I want to write a macro which brings up a msg box when a particular cell is
selected.

I've written the macro, and when I run it from the VB editor the message box
appears, but when I go back to excel and select the particular cell, it
doesn't work.

How do I "assign" the macro to the cell?

Thanks.

  #3   Report Post  
Harald Staff
 
Posts: n/a
Default Assign Macro

Rightclick the sheet tab in question, find the selection-change event and
call it from there after validating that it's the right cell, like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target(1).Address = "$B$12" Then Call MyMsgboxMacro
End Sub

If I were a catholic I'd go to church tomorrow and confess "Father, I have
sinned, I helped a stranger on the internet to create this terrible thing".
A MSGBOX when you enter a cell ? How can that be anything but annoying, what
good can it possible do, how would you react to such a thing, would you
read, digest and obey ? Don't, please don't.

Best wishes Harald

"James Hamilton" skrev i melding
...
I want to write a macro which brings up a msg box when a particular cell

is
selected.

I've written the macro, and when I run it from the VB editor the message

box
appears, but when I go back to excel and select the particular cell, it
doesn't work.

How do I "assign" the macro to the cell?

Thanks.



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
Assign Macro SUE M Excel Discussion (Misc queries) 1 September 22nd 07 09:00 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Assign a macro to Command Button Object dallin Excel Discussion (Misc queries) 2 July 13th 05 03:50 AM
Assign to macro missing Paul Excel Discussion (Misc queries) 2 January 22nd 05 09:55 AM
assign a macro to a control button ewan72 Excel Discussion (Misc queries) 1 December 3rd 04 02:04 PM


All times are GMT +1. The time now is 02:43 PM.

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"