This post will guide you how to use an Excel Macro VBA code to show a specified user form while clicking a cell or double clicking a cell in one cell in excel. How to open a user form just by clicking or double click on a cell. How to raise a User Form by double clicking on a cell.
Double Click Cell to Show User Form
If you want to click a cell to show user form, you can use the following VBA code to achieve the result. Just do the following steps:
#1 open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.
#2 then the “Visual Basic Editor” window will appear.
#3 click “Insert” ->”Module” to create a new module
#4 paste the below VBA code into the code window. Then clicking “Save” button.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Application.Intersect(Target, Range("A1:B3")) Is Nothing Then Cancel = True UserForm1.Show End If End Sub
#5 back to the current worksheet, then run double click any one cell in the range A1:B3. the UserForm1 is shown.
If you just want to click one cell then rasing a User Form, just use the following VBA code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("A1:B9")) Is Nothing Then UserForm1.Show End If End Sub