Environmental Commands?

  • Thread starter Thread starter Gunkie
  • Start date Start date
G

Gunkie

I'm somewhat new to Excel and want to do the following:

=IF(A2=B2, copy file named file1.txt to file2.txt, "")

Is there anyway to do that copy command in this kind of situation?

Thanks!

Scott Ghiz
www.SGSystems.com
 
one way is to try this
Public Sub fileopening()
If Range("a2") = Range(" b2") Then Workbooks.Open ("c:\my documents\book2.xls")
ActiveWorkbook.SaveAs "c:\my documents\book3.xls"

End Sub
 
There are a couple of things to consider.

The OP wanted to copy a txt file, not an xls file. If the filename.txt is
used, it will require going through the Text Import Wizard. And this is an
important step if the file contains things that look like dates, as Excel
will turn them into dates, reformatting them shamelessly.

Also, if A2=B2 is not true, whatever the active workbook is still gets saved
as book3.xls.
 
Back
Top