VBA Code

chef

Well-known Member
Joined
Jul 10, 2002
Messages
610
Office Version
  1. 365
  2. 2016
Hi
This might be simple but I'm not sure how to glue together.

I have 3 separate basic user forms with different contact lists

I have the following code that I got help with

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(False, False) = "D21" Then
UserForm1.Show
End If
End Sub


What I want to be able to do is have the user click on cel D21 then user form 1 shows or click on cell D22 then UserForm2 shows or D23 then UserForm3 shows.

I tried to copy and paste the above code and just change the cell and form reference but doesnt seem to work.

can someone give me a nudge on how to glue this together
 
Try

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(False, False) = "D21" Then
    UserForm1.Show
ElseIf Target.Address(False, False) = "D22" Then
    UserForm2.Show
ElseIf Target.Address(False, False) = "D23" Then
    UserForm3.Show
End If
End Sub
 
Upvote 0
Thank you so much for this and the quick reply.

Much appreciated
 
Upvote 0

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