Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Copy worksheet from one workbook to another workbook

Hi Joel thanks for that. i think it is almost there.

when run the open file "box" opens when you select the file to open the
following error message appears.

Run time error '1004'
Application-defined or object-defined error.
When you click debug the following is highlighted in your code

NewSht.PasteSpecial _
Paste:=xlPasteValues

Hope you can assist further.

Regards David
--
Regards
David


"joel" wrote:


Try this code. I used GetOpenfilename to open the workbook. I also
copies both the Values and the formats (not the formulas).


Sub MakeNewTotals()

Set Mytemplate = ThisWorkbook.Sheets("hscount")

fileToOpen = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls")
If fileToOpen = False Then
MsgBox ("Cannot Open file - Exiting Macro")
Exit Sub
End If

Set bk = Workbooks.Open(Filename:="fileToOpen")

With bk
'Create Data for sheet like this "01december2009"
DateStr = Format(Date, "ddmmmmyyyy")

'make new worksheet
Set NewSht = .Sheets.Add(after:=.Sheets(.Sheets.Count))
NewSht.Name = DateStr

Mytemplate.Cells.Copy
'paste values
NewSht.PasteSpecial _
Paste:=xlPasteValues

'paste formats
NewSht.PasteSpecial _
Paste:=xlPasteFormats

'save results
.save
End With


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165571

Microsoft Office Help

.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy worksheet from one workbook to another workbook


I left out cells

from

'paste values
NewSht.PasteSpecial _
Paste:=xlPasteValues

'paste formats
NewSht.PasteSpecial _
Paste:=xlPasteFormats


to

'paste values
NewSht.cells.PasteSpecial _
Paste:=xlPasteValues

'paste formats
NewSht.cells.PasteSpecial _
Paste:=xlPasteFormats


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165571

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Copy worksheet from one workbook to another workbook

Hi Joel worked a treat!! Thanks
--
Regards
David


"joel" wrote:


I left out cells

from

'paste values
NewSht.PasteSpecial _
Paste:=xlPasteValues

'paste formats
NewSht.PasteSpecial _
Paste:=xlPasteFormats


to

'paste values
NewSht.cells.PasteSpecial _
Paste:=xlPasteValues

'paste formats
NewSht.cells.PasteSpecial _
Paste:=xlPasteFormats


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165571

Microsoft Office 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
Copy worksheet from one workbook to a master workbook mvannatta Excel Worksheet Functions 3 April 15th 09 08:32 PM
How to Copy entire Worksheet from Workbook S to Workbook D kris Excel Programming 3 June 20th 07 02:03 PM
Copy Data from Workbook into specific Worksheet in other Workbook? kingdt Excel Discussion (Misc queries) 1 March 16th 06 07:55 PM
How do I copy a worksheet form a workbook in my workbook Neil Atkinson Excel Programming 1 October 12th 05 12:23 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 08:55 AM


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