![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 5
|
Can anybody tell me how I can make a macro run automatically at the point a user selects a cell on the worksheet before entering any data whether it is blank or not?
Thanks in advance. |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
have the macro run in. Insert/paste this code in; Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then RunMyMacro End If End Sub This is a Sheet Event procedure and runs when there is a change in the sheets selection. In this case a Macro Named [RunMyMacro] is called when ever A1 is selected, A1 being the Target to watch for in this example. |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Posts: 5
|
Ivan, thanks for the reply. I know how to that bit, but it requires me to enter something into the cell first. What I need to do is run the macro at the point of selecting the cell with the mouse pointer.
Pehaps it's daft as pointed out by friendly asfgfhgabcdsillyperson or whoever. |
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: May 2002
Location: Gothenburg, Sweden
Posts: 74
|
Quote:
Try Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) MsgBox "A" End Sub And you'll see that the msgbox appears as soon as you just change the selection.
__________________
/Niklas Jansson |
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
A1 is selected via mouse selection or keying over to it. |
|
|
|
|
|
|
#6 |
|
New Member
Join Date: May 2002
Posts: 5
|
Cheers guys, thats sorted things out.
Your help has been very much appreciated. Ivan..thanks for the email correspondence. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|