Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default workbook file name

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

  #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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default workbook file name

Hi Ranjith

Try the below macro which will list all the .csv (comma seperated values)
file names in the folder to Col A...Adjust the folder name to suit.

Sub FileswithinFolder()
Dim strFile As String, strFolder As String, intCount As Integer
strFolder = "c:\temp"
strFile = Dir(strFolder & "\*.csv", vbNormal)
Do While strFile < ""
intCount = intCount + 1
Range("A" & intCount) = strFile
strFile = Dir
Loop
End Sub

--
Jacob


"Ranjith Kurian" wrote:

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

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
Remove file Protection from an Excel workbook file from others whistler_z Excel Discussion (Misc queries) 2 December 12th 05 06:35 PM
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
having the same workbook in different file lazmanyak Excel Worksheet Functions 0 July 22nd 05 09:08 AM
"Workbook" file WayneB Excel Worksheet Functions 1 January 28th 05 08:03 PM
Is Workbook read-only because of file permission or because file is already opened? balexis Excel Programming 0 September 29th 04 02:29 PM


All times are GMT +1. The time now is 02:19 AM.

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"