ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   saving a worksheet as a .txt file with filename of specified cell (https://www.excelbanter.com/excel-programming/407043-saving-worksheet-txt-file-filename-specified-cell.html)

[email protected]

saving a worksheet as a .txt file with filename of specified cell
 
I am trying to save one worksheet in my workbook as a .txt file. I
want the name of the file to equal
Worksheets("Weekly").Range("A1"). (which will change montly, that's
why it cannot be a static defined name)
My Macro runs, but the problem is that it always equals the name of my
variable, which is "ThisFile". I need to save it in a specific
location U:\myfolder\ThisFile
Please review code below and provide assistance if you can.
Thanks!


Sub createplan()

ThisFile = Worksheets("Weekly").Range("A1")
ActiveWorkbook.SaveAs Filename:= _
"U:\myfolder\ThisFile", FileFormat:=xlText _
, CreateBackup:=False

End Sub

[email protected]

saving a worksheet as a .txt file with filename of specified cell
 
On Mar 3, 1:10 pm, wrote:
I am trying to save one worksheet in my workbook as a .txt file. I
want the name of the file to equal
Worksheets("Weekly").Range("A1"). (which will change montly, that's
why it cannot be a static defined name)
My Macro runs, but the problem is that it always equals the name of my
variable, which is "ThisFile". I need to save it in a specific
location U:\myfolder\ThisFile
Please review code below and provide assistance if you can.
Thanks!

Sub createplan()

ThisFile = Worksheets("Weekly").Range("A1")
ActiveWorkbook.SaveAs Filename:= _
"U:\myfolder\ThisFile", FileFormat:=xlText _
, CreateBackup:=False

End Sub


Use the & sign to concatenate strings:

Sub createplan()

ThisFile = Worksheets("Weekly").Range("A1")
ActiveWorkbook.SaveAs Filename:= _
"U:\myfolder\" & ThisFile, FileFormat:=xlText _
, CreateBackup:=False

End Sub

Cheers!
Nate


All times are GMT +1. The time now is 01:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com