Macro to automatically add a folder name into the macro

Hydro Man

New Member
Joined
Jun 29, 2009
Messages
48
Macro to automatically add a folder name into the macro
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
I Have the following macro below which performs well, what I would like to do is automatically add a folder name after the "\\aspen\set1\MLI_Archive\" for example: "\\aspen\set1\MLI_Archive\Folder Name" .
The folder name would be located on a worksheet in the same workbook named “Validation” in cell E13.
How do I automatically add the cell E13 folder name to the \\aspen\set1\MLI_Archive\ ?
Also how would I add a pop-up box so that a person could type in the folder name?
I may elect to run the auto population or the pop-up version, I haven’t decided yet, so two different macros would be required.
<o:p> </o:p>
Sub ListFilesInFolder()
'
' ListFilesInFolder Macro
<o:p> </o:p>
'Sub ListFilesInFolder()
Dim fs, f, f1, fc, s
a = 1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("\\aspen\set1\MLI_Archive\")
Set fc = f.Files
For Each f1 In fc
If Mid$(f1.Name, Len(f1.Name) - 3) = ".zip" Then
a = a + 1
Cells(a, 1) = f1.Name
End If
Next
End Sub
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
Thank you,
<o:p> </o:p>
Hydro Man
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Add it onto the string:
Rich (BB code):
t f = fs.GetFolder("\\aspen\set1\MLI_Archive\" & Sheets("Sheet Name Here").Range("E13"))
 
Upvote 0
Von Pookie,

Thank you very much it works great! I appreciate your help.

Would you know how to add a pop-up box such that a user could type in the folder and then the macro would go on from there?

Hydro Man
 
Upvote 0

Forum statistics

Threads
1,215,418
Messages
6,124,793
Members
449,189
Latest member
kristinh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top