PC Review


Reply
Thread Tools Rate Thread

Cell Selected to run Macro

 
 
Corey
Guest
Posts: n/a
 
      31st Oct 2006
If i select a Cell, how can i run a macro, rather than having a button?

Regards

Corey


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      31st Oct 2006
Right click on your sheet tab and paste this into the code window

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
MsgBox "Hello"
End If
End Sub

modify to suit your needs.

"Corey" wrote:

> If i select a Cell, how can i run a macro, rather than having a button?
>
> Regards
>
> Corey
>
>
>

 
Reply With Quote
 
Joerg
Guest
Posts: n/a
 
      31st Oct 2006
Through a SheetSelectionChange event:
1) Create a Workbook_SheetSelectionChange macro in the code section of
ThisWorkbook
2) Specify the cells that should trigger a macro

Example (macro is triggered when you select A3):

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
If Target.Address(0, 0) = "A3" Then
MsgBox "Hi, I'm cell " & Target.Address
End If
End Sub

Cheers,

Joerg






"Corey" <(E-Mail Removed)> wrote in message
news:OSkuoLI$(E-Mail Removed)...
> If i select a Cell, how can i run a macro, rather than having a button?
>
> Regards
>
> Corey
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to insert a cell after the selected cell PointerMan Microsoft Excel Programming 4 3rd Mar 2009 05:59 PM
Macro to transfer contents of 'Selected' cell to alternate cell. Gryndar Microsoft Excel Worksheet Functions 7 20th Dec 2008 09:58 PM
Run macro when cell is selected Corey Microsoft Excel Programming 7 29th Oct 2007 04:15 AM
Macro to take selected cells times a selected cell Craig Microsoft Excel Programming 4 24th Oct 2005 12:54 AM
Run macro as selected cell changes Maria Microsoft Excel Programming 1 14th Mar 2004 05:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 AM.