+ Reply to Thread
Results 1 to 3 of 3

Thread: Button Control

  1. #1
    Registered User
    Join Date
    05-20-2007
    Posts
    10

    Question Button Control

    This should be a simple one for you guys...
    Im new to using VBA/Macro but what I would like to be able to do is have a button (From Control or Form Tool Box?) That when its clicked it takes you to another sheet in the workbook or you know brings it into focus.

    Also since Im already asking for help, I also need to do one that opens another workbook.

    *edit*
    Im using Excel 02

    *edit*
    Disregard first part I found it here:
    http://www.excelforum.com/excel-new-users/337566-how-to-open-a-workbook-with-a-specific-worksheet-displayed-by-defa.html

    Worksheets("Sheet2").Activate
    But I still could use help on doing this for a workbook...
    (click button and another workbooks opens)

    Thanks in advance for any help,
    Jim
    Last edited by JimSolo; 05-20-2007 at 11:31 AM.

  2. #2
    Forum Guru Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hello Jim

    Will it always be the same workbook, or do you want to dynamically select which workbook to open every time the code is run? If the former, then code as simple as:

    Set wb = Workbooks.Open("MyWorkbookPath&Name")
    If the latter then maybe:

    Dim fName, wb As Workbook
    fName = Application.GetOpenFileName()
    If fName<>False Then
       Set wb = Workbooks.Open(fName)
    End If
    Hope this helps!

    Richard

  3. #3
    Registered User
    Join Date
    05-20-2007
    Posts
    10
    Well I tried what you said and got a compile error
    Heres what my code looks like:

    Private Sub CommandButton2_Click()
    Set wb = Workbooks.Open("C:\Documents and Settings\Jim\My Documents\LawnBarbers\Customer Database.xls")

    Sheets ("")
    End Sub

+ 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.2.0