File name in a macro

  • Thread starter Thread starter Jacktheg
  • Start date Start date
J

Jacktheg

Is there a way to determine a file name from within a macro?

My users open a file, called FILE1, and select a group of rows. They then
run a macro that I have installed on their computer. The macro only runs on
FILE1. If they have mistakenly opened FILE2, and then run the macro, they
get a "run time error." I would like to have the macro check to make sure
that the file called FILE1 is open before proceeding.

(I tried to put the filename in cell A1 and then check to make sure it was
the correct name, but when I did that, I lost the selection of rows that
starts the process. It checked the filename OK, but the macro bombed
because I had lost the selected rows)

Any help will be appreciated !!

Jack G
 
This worked perfectly. Thank you so much! Everybody here is so helpful and
over the years, you all have made me look like a very smart person. Thanks
again.

Jack G
 
Back
Top