Hello everyone ,
I trying to call this function inside a loop but I cannot make it works, basically what I 'd like to do is call this function for every cell in the selected range. I have attached the code please have look.
May anyone help me please?
Thanks in advance
Public Function GetFileProperty(myFile As String, myType As String) As String
'This creates an instance of the MS Scripting Runtime FileSystemObject class
Set oFS = CreateObject("Scripting.FileSystemObject")
Select Case UCase(Trim(myFile))
GetFileProperty = oFS.GetFile(myFile).DateCreated
GetFileProperty = oFS.GetFile(myFile).DateLastModified
GetFileProperty = oFS.GetFile(myFile).DateLastAccessed
GetFileProperty = oFS.GetFile(myFile).Size
GetFileProperty = "txt"
Public Sub SperiamoLoop()
Dim MyCell As Variant, Rng As Range
Set Rng = Sheets("Sheet1").Range("A2:A4") '''''sets the range to use
For Each MyCell In Rng ''''checks each cell in range
If MyCell <> "" Then '''''will only do something if the cell is not blank
Call GetFileProperty(myFile, myType) '''Put your code here
Else '''''if cell is equal to blank
Exit Function ''''then quit macro