A condition and a variable

B

Berj

I want to use a command or two in a macro in Excel where it checks for the
existence of a file "ABCD" in folder C:\2009. If the file exists, then it
should close the active file without saving. Otherwise if the file doesn't
exist in continues the execution of the rest of the macro lines.

Another question:
How can I assign a text value in a variable?
 
R

Rick Rothstein \(MVP - VB\)

First question: This code will test if the file ABCD.xls exists in the
c:\2009 directory and, if it does, exit the subroutine right then and
there...

If Len(Dir("C\2009\ABCD.xls")) > 0 Then Exit Sub

Second question: I not exactly sure how to read what you want here. I mean,
assignment to variables is kind of basic, for example...

TextVariable = "I am some text"

so I'm thinking maybe your question is not complete. Can you give us more
detail and an example?

Rick
 

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

Top