Active Member
September 27, 2021
Hi Experts,
I am having n number of rows with different path in one particular column. I build a macro to check all the path and if the folders are available in the specified path then will color the cell in grey and find out the number of files inside that particular folder in the next cell. If the folder is not available then I will highlight the rows in yellow color.
Here my concern is the Folderexists function of the FileSystemObject is not working properly and I am not getting the proper output. Sometimes even the folder is not available, it will highlight in grey color and return the file count and vice versa (folder is available but its highlighted with the yellow color). One more information is folders which i need to check are available in the mapped network local drive (Sharepoint).
Please give your suggestion to resolve this issue.
Regards,
Dhans.
Please find blow the code which i am using:
If fso.FolderExists(sourcepath) Then
r(, 165).Value = fso.GetFolder(sourcepath).Files.Count
r(, 164).Interior.Color = RGB(200, 200, 200)
Else
r(, 164).Interior.Color = vbYellow
End If
Trusted Members
December 20, 2019
Please add a workbook example to see what we are looking at
Personally i dont use FileSystemObject when checking if folders exist, i find it much easier to use
if len(dir(filepath & filename,vbdirectory) = 0
in a loop, espeically if the folders/files are listed in the workbook
Answers Post
Trusted Members
Moderators
November 1, 2018
1 Guest(s)