Modify VBA code

superfb

Board Regular
Joined
Oct 5, 2011
Messages
189
Office Version
  1. 2007
Platform
  1. Windows
Hi All,

I would like to modify this code, so a message box appears and asks me if i require file information from more than one locations, by this if i select yes each time each of the file locations will be listed.

As a consequence of this, it would then proceed to provide a list of file names and info from each of the locations

this is my current code:

VBA Code:
Option Explicit

Sub Get_Files_Information()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")

Dim FSO As New FileSystemObject
Dim fo As folder
Dim f As file

Set fo = FSO.GetFolder(sh.Range("B3").Value)

Dim last_row As Integer

For Each f In fo.Files
     last_row = sh.Range("A" & Application.Rows.Count).End(xlUp).Row + 1
     sh.Range("A" & last_row).Value = f.Name
     sh.Range("d" & last_row).Value = f.Path
     sh.Range("C" & last_row).Value = f.Type
     'sh.Range("D" & last_row).Value = f.DateLastModified
Next


MsgBox "Done"

End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,148,140
Messages
5,745,034
Members
423,917
Latest member
Frank1931

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
Top