+ Reply to Thread
Results 1 to 4 of 4

Open specific sheet depending on cell contents

  1. #1
    monkey harry
    Guest

    Open specific sheet depending on cell contents

    Hi,

    I'm fairly new to VB and need to create a macro which will open another
    workbook and more specifically a sheet within it depending on its
    contents.

    I'll try to be a bit clearer. Say cell "A1" contained the name of the
    sheet in another workbook, can I get a macro to read the contents of
    "A1" and open that specific sheet?

    As I said I'm fairly new to this, so the actual code to do it would
    excellent.

    Thanks


  2. #2
    Don Guillett
    Guest

    Re: Open specific sheet depending on cell contents

    The macro recorder is your friend. I just recorded this and then modified.

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 5/2/2006 by Don Guillett
    '

    '
    'Workbooks.Open Filename:="C:\yourfolder\yourfilename.xls"
    Workbooks.Open Filename:="C:\yourfolder\" & Range("a1") & ".xls"
    End Sub


    --
    Don Guillett
    SalesAid Software
    [email protected]
    "monkey harry" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I'm fairly new to VB and need to create a macro which will open another
    > workbook and more specifically a sheet within it depending on its
    > contents.
    >
    > I'll try to be a bit clearer. Say cell "A1" contained the name of the
    > sheet in another workbook, can I get a macro to read the contents of
    > "A1" and open that specific sheet?
    >
    > As I said I'm fairly new to this, so the actual code to do it would
    > excellent.
    >
    > Thanks
    >




  3. #3
    Ivan Raiminius
    Guest

    Re: Open specific sheet depending on cell contents

    Hi,

    supposing that cell A1 contains path and filename (like "c:\test.xls").
    you can use this code

    sub OpenFile()
    workbooks.open(range("a1").value)
    end sub

    To open the file "test.xls"
    This is just basic code without error trapping.

    Regards,
    Ivan


  4. #4
    monkey harry
    Guest

    Re: Open specific sheet depending on cell contents

    Thanks

    That's helped a lot!!!


+ 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