PC Review


Reply
Thread Tools Rate Thread

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

 
 
Simon
Guest
Posts: n/a
 
      27th Oct 2008
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
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      27th Oct 2008
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" <(E-Mail Removed)> wrote in message news:d927549e-1f51-4979-bd67-(E-Mail Removed)...
> 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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Check for Workbooks already open u473 Microsoft Excel Programming 2 3rd Dec 2008 10:28 PM
Check for open workbooks =?Utf-8?B?U3RlcGhlbiBD?= Microsoft Excel Programming 3 24th Oct 2006 12:47 PM
Check if Any workbooks are open =?Utf-8?B?S2V2aW4gUg==?= Microsoft Excel Programming 3 13th Sep 2006 07:55 PM
Check if several workbooks are open =?Utf-8?B?UmljYXJkbyBTaWx2YQ==?= Microsoft Excel Programming 2 23rd Feb 2006 09:49 PM
Check for open workbooks =?Utf-8?B?U3RldmUgUHJpY2U=?= Microsoft Excel Programming 5 3rd Dec 2004 03:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:30 AM.