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
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
I'd suspect the problem lies elsewhere (in the code you didn't post) since I can't see how you'd get a file count for a non-existent folder.
Thanks for the quick reply Purfleet. I will try and let you know the updates.
Thanks Velouria. The code which I pasted here is only place where I using the file count.