#1   Report Post  
nc
 
Posts: n/a
Default Workbook name

If I have a list of Excel files in a specific folder, can anyone help me
write a macro to obtain their names and enter it in a range as a list? If
posible without opening the files.

Thanks.

  #2   Report Post  
Peter Jausovec
 
Posts: n/a
Default

Hi,

Try using this code:

Sub Button1_Click()
FillFileNames "C:\\", 1
End Sub

Public Sub FillFileNames(path As String, column As Integer)
Dim MyFile As String
Dim Counter As Integer
Counter = 1

MyFile = Dir$(path & "*.xls")
Do While MyFile < ""
Sheet1.Cells(Counter, column).Value = MyFile
MyFile = Dir$
Counter = Counter + 1
Loop
End Sub

Hope this helps.

Peter
--
http://blog.jausovec.net


"nc" wrote:

If I have a list of Excel files in a specific folder, can anyone help me
write a macro to obtain their names and enter it in a range as a list? If
posible without opening the files.

Thanks.

  #3   Report Post  
Don Guillett
 
Posts: n/a
Default

One way
Sub FindExcelFiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String
FileLocation = "c:\ahorse\*.xls"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub

--
Don Guillett
SalesAid Software

"nc" wrote in message
...
If I have a list of Excel files in a specific folder, can anyone help me
write a macro to obtain their names and enter it in a range as a list? If
posible without opening the files.

Thanks.



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
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
Linking a cell to another workbook cell based on a variable name Brian Excel Discussion (Misc queries) 6 June 1st 05 11:54 PM
Unprotect Workbook Kent Excel Discussion (Misc queries) 1 February 4th 05 01:07 AM
make hidden window or workbook visible without specify the name mango Excel Worksheet Functions 1 December 30th 04 03:05 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 09:16 PM.

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

About Us

"It's about Microsoft Excel"