Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Easy Macro help

How can I create a macro that saves a worksheet as new file in a new
folder? To be more specifc. The main file has two worksheets. I want
worksheet two to be copied in a specific folder and the file to be
named the contents of a specific cell in worksheet 1.

I cant figure it out :(
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Easy Macro help

Hi,

This copies the second sheet from the active workbook and saves it with a
filename from A1 of the first sheet. Right click any sheet tab, view code and
paste the code in and run it.

Sub Stantial()
Dim wb As Workbook
Mypath = "C:\MyDocuments\" 'Change to suit
Fname = Sheets(1).Range("A1").Value
Sheets(2).Copy
Set wb = ActiveWorkbook
p = Sheets(1).Range("A1").Value
wb.SaveAs Mypath & Fname & ".xls"
wb.Close
End Sub

Mike

" wrote:

How can I create a macro that saves a worksheet as new file in a new
folder? To be more specifc. The main file has two worksheets. I want
worksheet two to be copied in a specific folder and the file to be
named the contents of a specific cell in worksheet 1.

I cant figure it out :(

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Easy Macro help

OOPS

This line isn't necessary, I put it there for debugging and forgot to delete
it

p = Sheets(1).Range("A1").Value

Mike

"Mike H" wrote:

Hi,

This copies the second sheet from the active workbook and saves it with a
filename from A1 of the first sheet. Right click any sheet tab, view code and
paste the code in and run it.

Sub Stantial()
Dim wb As Workbook
Mypath = "C:\MyDocuments\" 'Change to suit
Fname = Sheets(1).Range("A1").Value
Sheets(2).Copy
Set wb = ActiveWorkbook
p = Sheets(1).Range("A1").Value
wb.SaveAs Mypath & Fname & ".xls"
wb.Close
End Sub

Mike

" wrote:

How can I create a macro that saves a worksheet as new file in a new
folder? To be more specifc. The main file has two worksheets. I want
worksheet two to be copied in a specific folder and the file to be
named the contents of a specific cell in worksheet 1.

I cant figure it out :(

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Easy Macro help

Sub Make_New_Book()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:="C:\testing" _
& "\" & Range("A2").Value
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Edit "C:\testing" to suit your path and folder name.


Gord Dibben MS Excel MVP

On Sat, 13 Dec 2008 02:05:53 -0800 (PST), wrote:

How can I create a macro that saves a worksheet as new file in a new
folder? To be more specifc. The main file has two worksheets. I want
worksheet two to be copied in a specific folder and the file to be
named the contents of a specific cell in worksheet 1.

I cant figure it out :(


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
Hopefully easy macro question Brad Excel Programming 4 July 11th 08 02:04 PM
probably a relatively easy macro question.... [email protected] Excel Programming 2 December 19th 07 01:27 AM
Easy Macro joelbeveridge[_4_] Excel Programming 1 August 3rd 06 05:51 AM
Easy macro issue (I think) punter Excel Discussion (Misc queries) 3 May 29th 06 03:17 PM
easy macro? Ctech[_77_] Excel Programming 6 January 20th 06 01:43 AM


All times are GMT +1. The time now is 04:23 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"