If you want to store the file names in a dynamic array.
Here is the code-
Option Base 1
Sub filenamesinfolder()
Dim fld, fil As Object
Dim abc() As String, i As Long, j As Long
i = 1
Set fso = CreateObject("scripting.filesystemobject")
' folder path change it here.
Set fld = fso.getfolder("C:\Documents and Settings\user\Desktop\")
' save file names in a array
For Each fil In fld.Files
' redim and presever will increase the size of array without loosing the previous data stored in a array
ReDim Preserve abc(i)
abc(i) = fil.Name
i = i + 1
Next fil
' print the data of array in a worksheet
For j = LBound(abc) To UBound(abc)
Cells(j, 1) = abc(j)
Next
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to add a new menu on mouse right click "Workbook Navigation showing you the list of all open workbooks and worksheets in ea...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
Good One Sirji..!
ReplyDelete