+ Reply to Thread
Results 1 to 5 of 5

Command button help

Hybrid View

  1. #1
    Anna B
    Guest

    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. #2
    Toppers
    Guest

    RE: 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. #3
    Anna B
    Guest

    RE: 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. #4
    GS
    Guest

    RE: 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. #5
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1