Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default MACRO to save current worksheet with variable filename

I need to save the currently active sheet as a new workbook in a different
directory (folder). The filename is volatile and is contained in a cell on
the currently open sheet.
e.g. September, October ....
The saved file needs to be an Excel workbook format *.xls or *.xlsb
I am trying to write a MACRO to automate this file save and then retuirn to
the currently open sheet.
Can anyone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default MACRO to save current worksheet with variable filename

Try

Dim flToSave As String
Dim flName As String
Dim flFormat As Long

flFormat = ActiveWorkbook.FileFormat
flName = Sheets("Sheetname").Range("A1").Text & ".xls"

'If it is same as the current workbook
flToSave = ActiveWorkbook.Path
OR
'If it is a different path assign to that variable
flToSave = "m:\contract\"

ActiveWorkbook.SaveAs flToSave & "\" & flName, flFormat
OR
ActiveWorkbook.SaveCopyAs flToSave & "\" & flName


If this post helps click Yes
---------------
Jacob Skaria


"Wes_A" wrote:

I need to save the currently active sheet as a new workbook in a different
directory (folder). The filename is volatile and is contained in a cell on
the currently open sheet.
e.g. September, October ....
The saved file needs to be an Excel workbook format *.xls or *.xlsb
I am trying to write a MACRO to automate this file save and then retuirn to
the currently open sheet.
Can anyone help?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to insert current filename into worksheet? Ginko Excel Worksheet Functions 2 May 7th 08 12:32 PM
Save Current Workbook With Extended Filename Nate[_6_] Excel Programming 2 March 20th 07 07:19 PM
get the current filename as a variable Janis Excel Programming 10 September 2nd 06 02:01 PM
Doing a save with a variable filename? nbaj2k[_23_] Excel Programming 1 August 2nd 06 01:50 PM
USE MACRO TO SAVE WORKSHEET SELECTING FILENAME FROM CELLS David Vollmer Excel Programming 18 September 10th 05 03:32 PM


All times are GMT +1. The time now is 01:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"