ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Look for a string in filenames in a folder? (https://www.excelbanter.com/excel-programming/329954-look-string-filenames-folder.html)

FrigidDigit

Look for a string in filenames in a folder?
 
Hi all,

I have a spreadsheet in which I track invoices received from contractors.

I am trying to create a vba routine that will be triggered from a button to
search certain folders and subfolders for filename containing 2 strings.
Based on the results I will then populate and format certain cells. I have
no idea where to start. Could someone point me i9n the direction of some
code that i could work with?

Thank you very much



K Dales[_2_]

Look for a string in filenames in a folder?
 
The Dir function should help: Dir(FilePath) gives the files in the specified
path, and you can use wildcards, e.g: Dir(MyPath & "*abc*.xls"). The first
time you use Dir, you specify the path in this manner; then to find any other
qualifying files in the same path you just repeat the Dir function with a
zero-length string: Dir (""). Repeat until you get a zero-length string ""
as the result. See the Help file for complete details.



"FrigidDigit" wrote:

Hi all,

I have a spreadsheet in which I track invoices received from contractors.

I am trying to create a vba routine that will be triggered from a button to
search certain folders and subfolders for filename containing 2 strings.
Based on the results I will then populate and format certain cells. I have
no idea where to start. Could someone point me i9n the direction of some
code that i could work with?

Thank you very much




FrigidDigit

Look for a string in filenames in a folder?
 
Thanks for the response!!
FD

"K Dales" wrote in message
...
The Dir function should help: Dir(FilePath) gives the files in the
specified
path, and you can use wildcards, e.g: Dir(MyPath & "*abc*.xls"). The
first
time you use Dir, you specify the path in this manner; then to find any
other
qualifying files in the same path you just repeat the Dir function with a
zero-length string: Dir (""). Repeat until you get a zero-length string
""
as the result. See the Help file for complete details.



"FrigidDigit" wrote:

Hi all,

I have a spreadsheet in which I track invoices received from contractors.

I am trying to create a vba routine that will be triggered from a button
to
search certain folders and subfolders for filename containing 2 strings.
Based on the results I will then populate and format certain cells. I
have
no idea where to start. Could someone point me i9n the direction of some
code that i could work with?

Thank you very much







All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com