cell inspection

  • Thread starter Thread starter underhill
  • Start date Start date
U

underhill

Hi,

Im trying to drop into some VBA code but only if a specific cell i
selected. I am placing the call on the sheet change event. I a
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 stee
learning curve!

Thanks everyone!

:confused
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top