VBA check if full or partial name exists in folder

Holyfix

New Member
Joined
Oct 14, 2021
Messages
9
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hey everyone,
I am struggling with VBA code. I have a folder with pdf files. Every file contains one or more documents. These pdf files are named accordignly to the documents inside so I may have PDF file named 8947 (one document inside) or 8468 7638 7364 (three documents inside). Also, I have an Excel sheet with column containing these numbers and i need to check if every number (PDF file) exists in the folder or not. Is there a way to write VBA code which gives me YES or NO next to these numbers in Excel ?

Thank you very much
 
So I have tried to delete "ThisWorkbook.Path" from this part of the code "Set FolDir = FSO.GetFolder(ThisWorkbook.Path & "\Datafiles2")" and it seems to be working.
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Have you tried the Dir method, earlier suggested?
 
Upvote 0
I did, but it is says "Bad file name or number". I am still learning in this field so I kind of have no idea what is going on.
 
Upvote 0
You can just directly specify the folder path...
Code:
Set FolDir = FSO.GetFolder("C:\YourFolderName")
Dave
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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
Back
Top