View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Run macro when cell is selected

as soon as i select B5, the userform is displayed. if i select any other cell or
select more than one cell along with B5 it does not display.

--


Gary


"Corey" wrote in message
...
Gary,
Thanks for the reply.

The macro does not seem to run when i use it now ??
Even if the B5 is the ONLY cell selected.

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you can give this a try


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 Then
If Intersect(Target, Range("B5")) Is Nothing Then
Exit Sub
Else
UserForm2.Show
End If
end if
End Sub

--


Gary


"Corey" wrote in message
...
Is there a way to NOT run the code i ended up with IF there is MORE THAN 1
cell selected ?

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B5")) Is Nothing Then
Exit Sub
Else
UserForm2.Show
End If
End Sub

I use another macro to email the sheet, but as the B5 cell is inside the
sheet
range it rund the
macro again.

Is there a way around this ?

Corey....



"Dave Peterson" wrote in message
...
You can tie into a different event: Worksheet_SelectionChange



Corey wrote:

I know how to rtun a macro if a cell value is changed like :
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C5")) Is Nothing Then
Exit Sub
Else
'The cell you are monitoring has changed!
'Do whatever you need to do...
End If
End SubBut how can i have a macro run if the cell is simply Selected instead
?Corey....


--

Dave Peterson