Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Command button help

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Command button help

Double check the worksheet name as invalid name will give out of range error.

"Anna B" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Command button help

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.



"Toppers" wrote:

Double check the worksheet name as invalid name will give out of range error.

"Anna B" wrote:

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Command button help

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Command button help

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.

--
Regards,
Tom Ogilvy



"Anna B" wrote in message
...
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.



"Toppers" wrote:

Double check the worksheet name as invalid name will give out of range

error.

"Anna B" wrote:

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Command Button vs Form Button Bri[_3_] Excel Programming 2 February 3rd 06 08:18 AM
Command Button Patty2005[_6_] Excel Programming 1 August 7th 04 04:18 AM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"