Show userform when cell is selected

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
I need to be able to make a macro run to show a userform when a cell is selected. Hopefully this will fix the solution to my problem. I dont want an user to be able to enter data into this cell unless its through the useform. The cells defined name is "LotNumber".
 
This is what my code looks like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo ErrHandl
If Target.Name.Name = "LotNumber" Then LotNumber.Show
Exit Sub
ErrHandl:
Err.Clear
End Sub
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I renamed my UserForm as LotNumber and it still works for me.

It should work in any version of Excel from 97 onwards.

In the code window press CTRL + G to open the Immediate window then in that window type

?Application.EnableEvents

then press Enter. Does it return True?
 
Upvote 0
Am I suppose to define a cell name somewhere other to the left of the formula bar?
 
Upvote 0
Check in Name Manager that the named range applies to the correct cell (or, indeed, exists). Check for leading or trailing spaces.
 
Upvote 0
Just wanted to say thanks for the help... I've given up on the idea for now, may address it later. Going to do some research on ideas. It just didnt make ,uch sense because I am using that cell/name for other userforms as well and they all work great. Again thanks for your time. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,216,385
Messages
6,130,314
Members
449,572
Latest member
mayankshekhar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top