Macro to save file

  • Thread starter Thread starter Jodie
  • Start date Start date
J

Jodie

I would like to write a macro to save an excel file with the name being equal
to the first 3 digits of cell A1. Can this be done?
 
With activeworkbook
.saveas filename:="C:\somepath\" _
& left(.worksheets("Somesheetname").range("a1").value, 3) & ".xls", _
fileformat:=xlworkbooknormal
end with

If the value in A1 of that sheet is a number, you may want:

& left(format(.worksheets(somesheetname").range("a1").value, "000"), 3) & ...

so 1 is saved as 001.xls
 
Hi,

Try this

ActiveWorkbook.SaveAs Filename:=Left(Sheets("Sheet1").Range("A1"), 3) & ".xls"

Mike
 
Did you type the code into your module?

Maybe you missed a parens?

Copy the line and it works.


Gord Dibben MS Excel MVP
 
No

That particular error indicates a type in the line of code.

As I said before.......probably a missing parens.


Gord Dibben MS Excel MVP
 
Back
Top