VBA Coding for a Userform Command Button

Khan.saleena

New Member
Joined
Dec 17, 2012
Messages
4
Hello :)
So basically, I have created a Userform and it asks the question "Do you wish to continue to Log Out?" and there are two Command Buttons within that Userform. A "No" Command Button and a "Yes" Command Button.

If the individual was to press "Yes" then the Workbook would automatically shut down, however if the individual was to press "No" then it would re-locate them to another sheet within that same Workbook.

However I am having some trouble with the VBA coding for the "No" command button.

This is the current coding that is inputted, however it keeps getting highlighted in yellow -

Private Sub CommandButton1_Click()<o:p></o:p>
Application.Goto Worksheets("Sheet4"), Range("A1")<o:p></o:p>
Unload Me ' unloads the userform<o:p></o:p>
End Sub

Thank You :)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try

Rich (BB code):
Application.Goto Worksheets("Sheet4").Range("A1")
 
Upvote 0
I have tried the following -

Application.Goto Worksheets("Sheet4 (Order History)"), Range("A1")

and now it says the following -

Worksheets("Sheet4 (Order History)") = subscript out of range<subscript out="" of="" range=""> </subscript>
 
Upvote 0
As in my first post you need a . not a ,

Application.Goto Worksheets("Order History"). Range("A1")
 
Upvote 0
Oh sorry, I failed to see that first time
However i have implemented the full stop and it has worked
Thank you ever so much :)
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,122
Members
448,550
Latest member
CAT RG

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