LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Put worksheet names from inactive file into cells of active worksh


Hello-

I'm building a macro to go through a list of file names; for any .xls files
in that list, I want to create a list of the worksheets in that file. I want
to create this new list in the "master" file that stores the macro.

I would prefer if I could keep the focus on the "master" sheet, and pull in
the names from the open, but inactive, .xls file. The code below is my
attempt to do that, but I get a "Subscript out of range (Error 9)".

I'm open to other solutions that have the end result of putting a list of
tab names on the master sheet without altering any content in the other .xls
files. I also tried keeping the focus on the .xls file and sending the
results to the inactive master sheet, but that didn't fare any better.

Thank you all, these boards are incredibly helpful to those people like me
who get in over their heads with random Excel projects :)

My code:

Do Until HRow = GRow
Windows("Info Delivery Version 2.xls").Activate ***The "Master Sheet"
Sheets("Sheet1").Activate

FileName = Range("C" & HRow)
FileType = Range("D" & HRow)

If FileType < ".zip" Then
Application.EnableEvents = False
Workbooks.Open FileName:=Path & FileName
End If

Windows("Info Delivery Version 2.xls").Activate
Sheets("Sheet1").Activate

If FileType = ".xls" Then
Dim WS As Worksheet
For Each WS In Windows("FileName").Sheets ***Here's where I get an
error
Range("G" & IRow) = FileName
Range("H" & IRow) = WS.Name
IRow = IRow + 1
Next
ElseIf FileType < ".zip" Then
Range("G" & IRow) = Range("C" & HRow)
IRow = IRow + 1
End If
HRow = HRow + 1
Loop
 
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
XL 2007: can't change Inactive Excel Add ins to Active (DLL Com Addin as Visible) [email protected] Excel Programming 1 June 2nd 09 07:50 PM
Average IF? A1:A1000 has numbers - B1:B1000 has Active or Inactive wx4usa Excel Discussion (Misc queries) 8 October 23rd 07 10:32 PM
How can I have formatting options like merge cells ,Bold,active for the unlocked cells of the protected worksheet.Is it possible in excel? divya Excel Programming 2 July 20th 06 02:04 PM
Excel should indicate a list of inactive names 72947 Excel Discussion (Misc queries) 1 May 3rd 06 02:42 PM
Multiselect ListBox - Active/Inactive Items LCK[_2_] Excel Programming 2 November 3rd 05 12:39 AM


All times are GMT +1. The time now is 03:24 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"