how do i change this code to be a userform not a messagebox?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I was advised that as I wanted to position the messagebox in the top right of the screen I should use a userform instead,
I've created the userform (just called userform1) with two boxes yes / no but I don't know how to get it to replace my message box?
can someone please help me? what code do I use to get the same results but with my userform instead of the message box?
the code is:

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim answer
answer = MsgBox("Is This a Good Site?", vbYesNo + vbQuestion, "Empty Sheet")
If answer = vbYes Then
ActiveCell.Offset(0, 1) = "Good site"
ActiveCell.Offset(0, 1).Select
answer = ""
End If
End Sub
the code is placed in sheet2 and activates when I doubleclick a website in a cell.
Thanks

Tony
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
try
Code:
userform1.show
The problem you're going to encounter however is that the form itself won't pass back a return value, so you're going to have to include the code shown as part of the userform code, rather than in the calling sub
 
Upvote 0
Hi Weaver,
I'm normally ok with translating and sort these sort of thing out but I'm just getting totally lost, think i'll just stick to using it as it is! but thanks for your help.
Tony
 
Upvote 0
Fine by me, but you're really not that far away. If your userform has buttons, you can attach code to them. If you can do this then all you need to do is to make a function in the form make your sheet changes.
 
Upvote 0

Forum statistics

Threads
1,214,863
Messages
6,121,978
Members
449,058
Latest member
oculus

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