Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 110
Default Macro that runs when a cell is selected

I have a macro that I want to run when the user selects a cell. Can someone
give me the code that would do this?

Thanks in advance!

Daniel

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Macro that runs when a cell is selected

This runs when A1 is selected. Right click the sheet tab and select view
code. Paste the following...

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

Jim Thomlinson


"Daniel Bonallack" wrote:

I have a macro that I want to run when the user selects a cell. Can someone
give me the code that would do this?

Thanks in advance!

Daniel

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro that runs when a cell is selected

You can use a worksheet event:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Exit Sub
End If

Call MacroNameHere

End Sub

This checks to see if you selected any cell(s) in A1:B3. If you did, then it
calls MacroNameHere.

Rightclick on the worksheet tab that should have this behavior. Select view
code. Paste this code into the code window.

Change the range to check to what you want and change the name of the macro,
too.

Daniel Bonallack wrote:

I have a macro that I want to run when the user selects a cell. Can someone
give me the code that would do this?

Thanks in advance!

Daniel


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 110
Default Macro that runs when a cell is selected

Thank you Jim and Dave!
regards
Daniel

"Dave Peterson" wrote:

You can use a worksheet event:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Exit Sub
End If

Call MacroNameHere

End Sub

This checks to see if you selected any cell(s) in A1:B3. If you did, then it
calls MacroNameHere.

Rightclick on the worksheet tab that should have this behavior. Select view
code. Paste this code into the code window.

Change the range to check to what you want and change the name of the macro,
too.

Daniel Bonallack wrote:

I have a macro that I want to run when the user selects a cell. Can someone
give me the code that would do this?

Thanks in advance!

Daniel


--

Dave Peterson

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
I need a macro that runs other macros until P5=28 Jeff Excel Discussion (Misc queries) 6 May 7th 08 11:44 PM
VLOOKUP anchored cell reference changing when macro runs questor Excel Discussion (Misc queries) 2 September 14th 07 05:48 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Macro that runs in the background tomwashere2 Excel Discussion (Misc queries) 0 October 22nd 05 10:40 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM


All times are GMT +1. The time now is 09:35 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"