Calling a user form by clicking in a cell

  • Thread starter Thread starter Colin Griffiths
  • Start date Start date
C

Colin Griffiths

Hi, I've got a form that I want to popup when a user clicks on a certain
cell. The user will select a value from the form which will be returned to
that cell when the form closes. I have written the code for the form and it
works ok when I attach it to the properties of a button etc. But thats not
really what I want as there are several cells in a worksheet that have to
trigger this event so I dont want to litter it with multiple buttons. So my
question is how do you trigger an even when a user clicks on a cell (or a
cell in a named range)


Cheers,


Griff
 
Hi Griff

Rightclick the sheet tab, choose "view code", paste this in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$4" Then UserForm1.Show
End Sub

Rename the userform name to fit if you gave it a cool name.
Your task is perhaps a little more complex (like passing the address to the form for
returning data maybe) but I hope this get you started. Post back if not.
 
Back
Top