startup macro problem

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

Need your help.

I have an Excel workbook that does specific
tasks automatically when it is started. I
have been trying to add one more task but
am having real problems doing so.

What I want to do is to add code in my current
workbook startup macro that will go to the C:\
drive and look for a specific file (e.g. targetfile.xls)
at a specific location (e.g. C:\TARGET FOLDER\).
If the file is found at that specific location all I
want the macro to do is to put a value of "TRUE" on
worksheet 1 in cell A1. If the macro does not find the
file I want it to put a value of "FALSE" in cell A1. I
don't want any alerts or messages telling me that the
file could not be found, if that is the case.

I think my problems in getting this to work
thus far have been related to "error handling"
issues if the file is not found. I can't
seem to get the needed code right. Don't know if I
am experiencing brain cell loss or am simply getting
confused due to the noise from the Cicadas that have
taken over my neighborhood. Any help getting me back on
track will be greatly appreciated.
 
Scott,

You can use code like

If Dir("C:\Target Folder\Target File.xls") = "" Then
' not found
Range("A1").Value = False
Else
' found
Range("A1").Value = True
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top