Click or Double Click Cell to Show userform

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.

Get the position of the nth using excel vba1

#2 then the “Visual Basic Editor” window will appear.

#3 click “Insert” ->”Module” to create a new module

convert column number to letter3

#4 paste the below VBA code into the code window. Then clicking “Save” button.

click cell to show userform1

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.

click cell to show userform2

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

 

 

Leave a Reply