Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing excel sheet names 1

Status
Not open for further replies.

hd65

Technical User
Aug 17, 2000
27
US
I have a spread sheet with several sheets. I want to --From another excel file-- get all the sheet names and list them in a combo box via a macro. Is this possible?
 
Why? Have you been able to resolve your question? If so, let us all know. If not, as you say "never mind" :)
 
Hasit,
Here is how I did it....May not be the best way or
a way to share...
but it works.

Sub OK_Click()
Dim sht()
File = FilenameBox.Value + ".xls"
Workbooks.Open FileName:=File
ActiveWindow.WindowState = xlMinimized
Workbooks(File).Activate
i = 0
For Each wks In Worksheets
ReDim sht(i)
sht(UBound(sht)) = i
i = i + 1
Next wks
a = 0
For Each ws In Worksheets
sht(a) = ws.Name
a = a + 1
Next ws
Workbooks(File).Close SaveChanges:=True
y = 0
For Each Item In sht
ComboBox1.AddItem sht(y)
y = y + 1
Next Item
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top