LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default programmatically save new workbook with custom name & location

Good morning,
The following code works to copy the last submission entered in the "Site
Reading Log' to a new workbook. The problem is that this code doesn't name
the new workbook.

Question:
Can this code be modified to:
a) save the new workbook as 'Copreco Reading'
b) save the new workbook to the users Desktop

Sub ExportCoprecoReadingData()
Const sourceSheet = "Site Reading Log" ' source
Dim sourceBook As String
Dim destBook As String
Dim sourceRange As Range
Dim destRange As Range

Application.ScreenUpdating = False
sourceBook = ThisWorkbook.Name
Workbooks.Add ' create new book
destBook = ActiveWorkbook.Name
Windows(sourceBook).Activate
Worksheets(sourceSheet).Select

Set sourceRange = ActiveSheet.Rows("1:1")
Set destRange = Workbooks(destBook).Worksheets("Sheet1").Rows("1:1 ")
destRange.Value = sourceRange.Value

'change "A" to column with data in last row
Range("A" & Rows.Count).End(xlUp).Select
Set sourceRange = ActiveSheet.Rows(ActiveCell.Row & ":" & ActiveCell.Row)
Set destRange = Workbooks(destBook).Worksheets("Sheet1").Rows("2:2 ")
destRange.Value = sourceRange.Value
Set sourceRange = Nothing
Set destRange = Nothing

End Sub

--
Carlee
 
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
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
delete workbook from one location and save workbook to new locatio Damien Excel Programming 5 August 3rd 06 03:05 PM
Programmatically Set the Workgroup Templates location joe215 Excel Programming 2 November 10th 05 07:10 PM
Macro in Excel 2002 to save a workbook to a FTP location Lloyd Excel Discussion (Misc queries) 0 December 21st 04 02:49 PM
Programmatically saving a workbook to a ftp location fails Lloyd Excel Programming 0 December 20th 04 09:17 PM


All times are GMT +1. The time now is 11:39 PM.

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"