Hello
I am fairly new to VBA, however I have an excel spreadsheet that contains various addresses.
Each address has a folder . For each address there should be 3 files. The files have their own abbreviations I.e the picture file has PIC at the end. Each file is named in the format address_abbreviation I.e 1ABCStreet_PIC.
I have been trying to identify if any files are missing using couple of options:
1. Function FileExists(sFile As String)
sPath = “Folder location” & sFile & “_PIC.pdf”
FileExists = DIR(sPath) <> “”
End Function
Then for each address in the spreadsheet I have been inserting the formula =If(FileExists(A1), “y”, “n”). Where A1 has the address in the same format as that the files have been named.
It always returns “n” and I am unsure where I am going wrong.
2. Sub DIR()
Dim Filename As String
Filename=“Folder location” & A1 & “_PIC.pdf”
If Filename = VBA.Constants.vbNullString then
Sheet1.Range(“B1”).Value = “n”
Else
Sheet1.Range(“B1”).Value=“y”
End If
End sub
I believe there is an issue with trying to specify the filename using data from excel cells, but that is just a guess and any help would be much appreciated.
Bookmarks