Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Determine sheets in file

Fantastic! Thank you!

"Tom Ogilvy" wrote in message
...
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" wrote in message
...
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
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
Determine Excel file version with no file extension. tjlumpkin Excel Discussion (Misc queries) 2 July 23rd 09 06:59 AM
How can I determine which sheets meet criteria? tgcali Excel Discussion (Misc queries) 0 May 14th 08 07:38 PM
Determine what sheets are linked to sheet A David Links and Linking in Excel 3 April 24th 08 06:03 PM
In 3 active sheets in wkbk, determine& display the # of sheets that have data wrpalmer Excel Discussion (Misc queries) 1 November 4th 05 02:01 PM
How do I determine if it is a new file or an existing file? Conan Kelly Excel Programming 2 July 20th 05 04:56 PM


All times are GMT +1. The time now is 01:06 PM.

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

About Us

"It's about Microsoft Excel"