Thread: cell inspection
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default cell inspection

Right-click the sheet tab and select View Code

Drop this code in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B4")) Is Nothing And Target.Cells.Count
= 1 Then
MsgBox "event code"
End If
End Sub


The code ensures the cell count of the selection is just 1 cell
(Target.Cells.Count = 1)
It ensures the selection is at address B4


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"underhill" wrote in message
...

Hi,

Im trying to drop into some VBA code but only if a specific cell is
selected. I am placing the call on the sheet change event. I am
assuming this is the correct way to do it.

The pseudocode would be as follows:

If cell x is selected then
event
endif
How is this done in VBA for EXCEL?

I am experienced in VBA for ACCESS but ECXEL is going to be a steep
learning curve!

Thanks everyone!




--
underhill
------------------------------------------------------------------------
underhill's Profile:
http://www.excelforum.com/member.php...fo&userid=4786
View this thread: http://www.excelforum.com/showthread...hreadid=274084