double click userform

Moses99

New Member
Joined
Jul 2, 2019
Messages
11
I want to double click on a row, application.workbook.worksheet(1).range ("A1"). When I double click on it it shows a pop out a userform

Thank you in advance
 

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,003
you need to go to the code for the worksheet, and create a worksheet_DblClick event with something like this:

If target.col = 1 and target.row = 1 then Call LoadForm (or whatever your macro is)
 

Moses99

New Member
Joined
Jul 2, 2019
Messages
11
hi johnny C

i tried this for initial testing

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 And Target.Row = 1 Then
MsgBox ("HI")

End If

End Sub

it doesnt work. I want my double click only work on row A only
 

Moses99

New Member
Joined
Jul 2, 2019
Messages
11
sorry about that, it works, i wrote it like below

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 1 And Target.Row = 1 Then
MsgBox ("Hi")

End If

End Sub

How could I write a code for the entire colum A1 until all below
 

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,003
I'll have a look tomorrow. My PC is running an all-night job at the moment.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,392
Office Version
365
Platform
Windows
If you want to use double click try this.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Column = 1 And Target.Row = 1 Then
        Cancel = True
        MsgBox "Hi!"
    End If
End Sub
 

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,003
Thanls Norie.
IIRC BeforeDoubleClick isnt listed as an option on wrksheet events, or it didnt used to be but you could still use it.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,392
Office Version
365
Platform
Windows
Pretty sure it is, that's how I got the code stub anyway.:)
 

Forum statistics

Threads
1,085,488
Messages
5,383,944
Members
401,867
Latest member
hpares

Some videos you may like

This Week's Hot Topics

Top