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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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