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!
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!
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!
>
>
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!
> >
> >
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks