View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MRT MRT is offline
external usenet poster
 
Posts: 26
Default workbook file name

Try...

Private Function GetPath()
Dim strPath As String
MsgBox "Select Folder"
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = True Then
strPath = .SelectedItems(1)
End If
End With
GetPath = strPath
End Function

Sub File_List()
Dim strPath As String
Dim strFName As String
Dim n As Long
strPath = GetPath
If strPath = "" Then Exit Sub
If Right(strPath, 1) < "\" Then
strPath = strPath & "\"
End If
strFName = Dir(strPath & "*.csv")
Do While strFName < ""
n = n + 1
Cells(n, 1).Value = strFName
strFName = Dir()
Loop
End Sub

HTH
--
MRT

"Ranjith Kurian" wrote in message
...
I have nearly 50 workbooks(.csv format) in a folder, i need a macro to copy
all the workbooks Names to a new worksheet.