Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rog Rog is offline
external usenet poster
 
Posts: 18
Default Macro question - Need to copy data & formatting to another workboo

I am trying to copy a worksheet from one Excel workbook to another workbook
using a macro, but all the formatting is lost using a copy/paste. How can I
do this since the path and workbook names are different? I cannot use the
copy worksheet feature by right clicking the tab because the destination
workbook is not open at the time of the copy. I have defined the path in the
macro and it works fine except for the formatting problem. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro question - Need to copy data & formatting to another workboo


This should select all cells on the sheet for which it is run, i don
know whether it works as i just kind of lashed it together withou
testing it (probably because i dont really have a clue what i'
doing!), but i copied a sheet by selecting every cell and pasting th
cells like below into a newly added sheet.

Hope it gets you some way if not all the way there!

P.S you might need to add a With statement to add the sheet in th
newly opened workbook.

Regards,
Simon

Sub ShtCopy()
Cells.Select
Selection.Copy
'''OPEN THE YOUR RECEIVING WORKBOOK HERE'''
'''SELECT YOUR NEWLY OPENED WORKBOOK'''
Sheets.Add
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteColumnWidths
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Save
'''SELECT YOUR ORIGINAL WORKBOOK'''
'''CLOSE YOUR RECEIVING WORKBOOK'''
End Su

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=56556

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro question - Need to copy data & formatting to another workboo

Hello Rog,

Try this piece of code:
Sub copy_to_closed_workbook
Sheets("Sheet1").Select
Workbooks.Open Filename:="C:\Filename.xls"
Windows("Current Workbook.xls").Activate
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Workbooks("Filename.xls").Sheets(1)
End Sub

Let me know if it works.

Rog wrote:
I am trying to copy a worksheet from one Excel workbook to another workbook
using a macro, but all the formatting is lost using a copy/paste. How can I
do this since the path and workbook names are different? I cannot use the
copy worksheet feature by right clicking the tab because the destination
workbook is not open at the time of the copy. I have defined the path in the
macro and it works fine except for the formatting problem. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Rog Rog is offline
external usenet poster
 
Posts: 18
Default Macro question - Need to copy data & formatting to another wor

It looks like it will work great! Thank you!

" wrote:

Hello Rog,

Try this piece of code:
Sub copy_to_closed_workbook
Sheets("Sheet1").Select
Workbooks.Open Filename:="C:\Filename.xls"
Windows("Current Workbook.xls").Activate
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Workbooks("Filename.xls").Sheets(1)
End Sub

Let me know if it works.

Rog wrote:
I am trying to copy a worksheet from one Excel workbook to another workbook
using a macro, but all the formatting is lost using a copy/paste. How can I
do this since the path and workbook names are different? I cannot use the
copy worksheet feature by right clicking the tab because the destination
workbook is not open at the time of the copy. I have defined the path in the
macro and it works fine except for the formatting problem. Thanks.



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
data from one workbook automatically entered into another workboo. cfrt Excel Discussion (Misc queries) 1 September 10th 08 01:11 AM
Duplicating/Mirror Data into another worksheet within same workboo TJ Excel Worksheet Functions 1 May 6th 08 09:39 AM
How can I copy the header and footers onto every page on a workboo Lesley Shand Excel Worksheet Functions 1 September 1st 07 03:34 PM
Can you code a macro so it runs multiple times in the same workboo dpmac Excel Discussion (Misc queries) 2 April 18th 06 07:40 PM
How do I copy a worksheet without the link to the original workboo Reliabengr Excel Discussion (Misc queries) 1 August 31st 05 01:17 AM


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