Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving a workbook with a variable name


I have my workbook open. I want to open a new workbook, copy the dat
from my active sheet to the active sheet of the new workbook, then sav
the new workbook with a file name that is the value in a cell on m
original active sheet. I understand that the new workbook will be save
in the same directory where my original workbook is located.

When recording a macro, here is what I come up with. I think all I'
missing is the file name parameter in the save portion (where I hav
the ???).

Workbooks.Add
Windows("Book1").Activate
Sheets("Sheet 1").Select
Range("A1:A3").Select
Selection.Copy
Windows("Book2").Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"???", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Windows("Book1").Activat

--
mwc091
-----------------------------------------------------------------------
mwc0914's Profile: http://www.excelforum.com/member.php...fo&userid=2413
View this thread: http://www.excelforum.com/showthread.php?threadid=39020

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Saving a workbook with a variable name

Dim bk as Workbook, sh as Worksheet
set sh = Workbooks("Book1").Sheets("Sheet 1")
set bk = Workbooks.Add
sh.Range("A1:A3").Copy _
Destination:=Activesheet.range("A1")
bk.SaveAs Filename:= _
sh.Range("A4").Value & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Windows("Book1").Activate

--
Regards,
Tom Ogilvy


"mwc0914" wrote in
message ...

I have my workbook open. I want to open a new workbook, copy the data
from my active sheet to the active sheet of the new workbook, then save
the new workbook with a file name that is the value in a cell on my
original active sheet. I understand that the new workbook will be saved
in the same directory where my original workbook is located.

When recording a macro, here is what I come up with. I think all I'm
missing is the file name parameter in the save portion (where I have
the ???).

Workbooks.Add
Windows("Book1").Activate
Sheets("Sheet 1").Select
Range("A1:A3").Select
Selection.Copy
Windows("Book2").Activate
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"???", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
Windows("Book1").Activate


--
mwc0914
------------------------------------------------------------------------
mwc0914's Profile:

http://www.excelforum.com/member.php...o&userid=24130
View this thread: http://www.excelforum.com/showthread...hreadid=390203



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
Saving as variable file name leerem Excel Discussion (Misc queries) 1 September 29th 08 10:30 AM
Saving Workbook with Variable JJ Excel Programming 2 December 2nd 04 10:44 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving Range Locatoin into a Variable Jake Marx Excel Programming 4 September 10th 03 10:08 PM
Saving Range Locatoin into a Variable Bob Phillips[_5_] Excel Programming 0 September 10th 03 09:13 PM


All times are GMT +1. The time now is 05:06 AM.

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

About Us

"It's about Microsoft Excel"