ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   missing file (https://www.excelbanter.com/excel-programming/368122-missing-file.html)

jnewl

missing file
 
i have a macro that retrieves csv files, creates pivot tables and builds
excel workbooks. these csv files are from different programs, so my macro
executes a series of macros to get the excel books.
this job is run monthly and some of these files are not available because of
a lack of data. what statement can i use to check for missing file and bypass
the macro so that my master macro does not abend?

thanks

ADG

missing file
 
There are a number of ways to check a file exists The DIR function is one.
The below returns WIN.INI if the file exists or an empty string if it does
not you could check the string length that this function returns to tell if
your file exists

Dir("C:\WINDOWS\WIN.INI")
--
Tony Green


"jnewl" wrote:

i have a macro that retrieves csv files, creates pivot tables and builds
excel workbooks. these csv files are from different programs, so my macro
executes a series of macros to get the excel books.
this job is run monthly and some of these files are not available because of
a lack of data. what statement can i use to check for missing file and bypass
the macro so that my master macro does not abend?

thanks


Ron de Bruin

missing file
 
You can use this to test if a file exist

If Dir("C:\Data\test.xls") < "" Then MsgBox "Run your code"



--
Regards Ron de Bruin
http://www.rondebruin.nl



"jnewl" wrote in message ...
i have a macro that retrieves csv files, creates pivot tables and builds
excel workbooks. these csv files are from different programs, so my macro
executes a series of macros to get the excel books.
this job is run monthly and some of these files are not available because of
a lack of data. what statement can i use to check for missing file and bypass
the macro so that my master macro does not abend?

thanks





All times are GMT +1. The time now is 02:08 PM.

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