Open Two Different UserForms by Clicking Specific Cells

gugumnd

New Member
Joined
May 27, 2018
Messages
8
Im trying to make a vba program that will open specific userform by clicking specific cells. I have two forms Userform1 and UserForm2 that I want to show on the same Worksheet when a user click specific cell. Example; when Range("A1") is doubleclicked show UserForm1, when Range("A5") is doubleclicked show UserForm2.

I tried the code below but it only works for Range("A1") and Userform1. I dont know how to add for Range("A5") and Userform2.


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Double click
If Not Application.Intersect(Target, Worksheets("Sheet1").Range("A1")) Is Nothing Then
Cancel = True
UserForm1.Show
End If



Please help. Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi & welcome to the board.
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Double click
If Not Intersect(Target, Range("A1")) Is Nothing Then
   Cancel = True
   UserForm1.Show
ElseIf Not Intersect(Target, Range("A5")) Is Nothing Then
   Cancel = True
   UserForm2.Show
End If
End Sub
 
Last edited:
Upvote 0
Hi Fluff,

It works!! I was able to load different userform on the same worksheet. Thanks a lot for the help.:)
 
Upvote 0
glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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