ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to check IF new folder has any workbooks in it. (https://www.excelbanter.com/excel-programming/419091-how-check-if-new-folder-has-any-workbooks.html)

Simon[_2_]

How to check IF new folder has any workbooks in it.
 
Hi,

Every month I run macros which populate the latest months folder. I
wish to run a macro to test whether I have ran this macro yet this
month. So I thought of running a macro that tried to call up a known
file from that folder and if a file is there, a MsgBox returns "Macro
already ran this month".

However if I run it and nothing is there, becuase I asked for the
designated workbook to be there, it will cause a debug error.

How do I get round this (I thought with an If statement)

Thanks in advance :-)

Simon

Ron de Bruin

How to check IF new folder has any workbooks in it.
 
You can use Dir to test if the file is there

If Dir("C:\Testfolder\ron.xls") < "" Then
'is there
Else
'not there
End If


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Simon" wrote in message ...
Hi,

Every month I run macros which populate the latest months folder. I
wish to run a macro to test whether I have ran this macro yet this
month. So I thought of running a macro that tried to call up a known
file from that folder and if a file is there, a MsgBox returns "Macro
already ran this month".

However if I run it and nothing is there, becuase I asked for the
designated workbook to be there, it will cause a debug error.

How do I get round this (I thought with an If statement)

Thanks in advance :-)

Simon



All times are GMT +1. The time now is 11:15 AM.

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