+ Reply to Thread
Results 1 to 3 of 3

Determine sheets in file

  1. #1
    Steph
    Guest

    Determine sheets in file

    If I had a list of files (full file path), how could I loop through them and
    capture all the sheet names within each file.

    For example, file names in column A, sheet names in B forward.

    Thank you!



  2. #2
    Tom Ogilvy
    Guest

    Re: Determine sheets in file

    Dim rng as Range, cell as Range, sh as Worksheet
    Dim j as Long
    set rng = Range(cells(1,1),Cells(1,1).End(xldown))
    for each cell in rng
    set bk = Workbooks.Open(cell.Value)
    j = 2
    for each sh in bk.Worksheets
    cells(cell.row,j).Value = sh.name
    j = j + 1
    Next
    bk.close SaveChanges:=False
    Next

    --
    Regards,
    Tom Ogilvy



    "Steph" <[email protected]> wrote in message
    news:%[email protected]...
    > If I had a list of files (full file path), how could I loop through them

    and
    > capture all the sheet names within each file.
    >
    > For example, file names in column A, sheet names in B forward.
    >
    > Thank you!
    >
    >




  3. #3
    Steph
    Guest

    Re: Determine sheets in file

    Fantastic! Thank you!

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Dim rng as Range, cell as Range, sh as Worksheet
    > Dim j as Long
    > set rng = Range(cells(1,1),Cells(1,1).End(xldown))
    > for each cell in rng
    > set bk = Workbooks.Open(cell.Value)
    > j = 2
    > for each sh in bk.Worksheets
    > cells(cell.row,j).Value = sh.name
    > j = j + 1
    > Next
    > bk.close SaveChanges:=False
    > Next
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Steph" <[email protected]> wrote in message
    > news:%[email protected]...
    > > If I had a list of files (full file path), how could I loop through them

    > and
    > > capture all the sheet names within each file.
    > >
    > > For example, file names in column A, sheet names in B forward.
    > >
    > > Thank you!
    > >
    > >

    >
    >




+ 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