Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Command button help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anna B - 28 Feb 2006 19:53 GMT
I have some command buttons on a userform.  I want each of these command
buttons to take me to a different worksheet in the workbook.  I am so new to
VBA and don't really understand it at all.  I have the command button on the
form, I double click it to bring up the code window and it automatically puts
in

Private Sub EmployeeBenefits Click_()
End Sub

(EmployeeBenefits is the name of my command button)  I have five of them
with different names)

I added the following to try to get it to go to the sheet...

Sheets("Employee Benefits").Select

It says it is out of range.  Can someone help?  I am clueless.  Thanks.
Toppers - 28 Feb 2006 20:12 GMT
Double check the worksheet name as invalid name will give out of range error.

> I have some command buttons on a userform.  I want each of these command
> buttons to take me to a different worksheet in the workbook.  I am so new to
[quoted text clipped - 13 lines]
>
> It says it is out of range.  Can someone help?  I am clueless.  Thanks.
Anna B - 28 Feb 2006 20:27 GMT
Ok great, that worked, except, now, my userform stays in the front, and
behind it is my employee benefits worksheet.  I guess I need to do something
else to show it?  Could I use show instead of select?  Thanks.  

> Double check the worksheet name as invalid name will give out of range error.
>
[quoted text clipped - 15 lines]
> >
> > It says it is out of range.  Can someone help?  I am clueless.  Thanks.
GS - 28 Feb 2006 22:28 GMT
Hi Anna B,

You need to dismiss the userform. You can click the close button in the
corner ( X ), or add this line after Sheets("SheetNameHere").Select:

  Unload Me

That will close the form so you can continue working on the selected sheet.

Regards,
GS
Tom Ogilvy - 28 Feb 2006 22:49 GMT
Do you use

userform1.Show vbModeless
in xl2000 or later

If so, the user will be able to select and work with the worksheet, but the
userform will still stay in the forefront.

If your just trying to work with the ranges on the worksheet, there is no
reason to select anything.

Since you haven't said what you are actually trying to achieve, why not talk
about that.

Signature

Regards,
Tom Ogilvy

> Ok great, that worked, except, now, my userform stays in the front, and
> behind it is my employee benefits worksheet.  I guess I need to do something
[quoted text clipped - 19 lines]
> > >
> > > It says it is out of range.  Can someone help?  I am clueless.  Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.