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 pop up button on mouse right click menu and as soon as you click on it . It shows you multiple buttons with macro a...
-
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
Good One Sirji..!
ReplyDelete