View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Otto Moehrbach
 
Posts: n/a
Default run macro when cell is selected

Dave
Thanks for that. I will remember it. I hope. Otto
"Dave Peterson" wrote in message
...
Just a word of warning:

If Target.Address = "$a$1" Then macro1

won't ever fire macro1--assuming "option compare text" isn't included.

.Address will be upper case:
If Target.Address = "$A$1" Then macro1

===
I like this format:

if intersect(target,me.range("a1")) is nothing then
'do nothing
else
macro1
end if

I find it easier to type (no case worries) and easier to add more cells to
the
check.



Otto Moehrbach wrote:

Change what you to the following:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$a$1" Then macro1
End Sub

"beauty_bobaloo" wrote in
message
...
I have been trying to figure this out for hours now.

I just want to run a macro when a certain cell is selected.
upon investigation, i have found that I can right click on the sheet
tab
and
view the code. I can then add the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$a$1" Then
run(macro1)
end if
End Sub

I know that this doesn't work, but I can't figure out how to get it to
work.
Any help will be greatly appreciated.

thanks in advance

Melissa


--

Dave Peterson