Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Copy & Past Macro Question

Hello,

I want to write a macro that takes certain tabs of a workbook and copies
them to a new workbook then breaks all links in the newly created workbook.

Can this be done?

If so what would the VBA look like?

Thanks so much :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Copy & Past Macro Question

mydogpeanut

Yes it can be done. Here are two routines that work pretty good.
Set Public variables Public LinkPath, Mastr As String

Sub CopyTheSheets()

Dim DestWB As Workbook
Dim ws As Worksheet
Dim Wrkbk As String
LinkPath = ActiveWorkbook.FullName
Mastr = ActiveWorkbook.Name
'Wrkbk = Sheets("Sheet1").Range("B3")
'This should be the name of the new workbook.
'you place the name in a cell as I did.(i.e. Book1.xls)
Set DestWB = Workbooks(Wrkbk)

For Each ws In ThisWorkbook.Worksheets
With DestWB.Worksheets
ws.Copy after:=.Item(.Count)
Next ws

Linkage (LinkPath) 'This will change the link
ActiveWorkbook.Save
Windows(Mastr).Activate
End Sub

Function Linkage(link1 As String)
'Undo the links to the Master file and set to current book
ActiveWorkbook.ChangeLink link1, ActiveWorkbook.FullName, xlExcelLinks
End Function

"mydogpeanut" wrote:

Hello,

I want to write a macro that takes certain tabs of a workbook and copies
them to a new workbook then breaks all links in the newly created workbook.

Can this be done?

If so what would the VBA look like?

Thanks so much :)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Copy & Past Macro Question

Thank you... I'm going to give it a try :)

"JRForm" wrote:

mydogpeanut

Yes it can be done. Here are two routines that work pretty good.
Set Public variables Public LinkPath, Mastr As String

Sub CopyTheSheets()

Dim DestWB As Workbook
Dim ws As Worksheet
Dim Wrkbk As String
LinkPath = ActiveWorkbook.FullName
Mastr = ActiveWorkbook.Name
'Wrkbk = Sheets("Sheet1").Range("B3")
'This should be the name of the new workbook.
'you place the name in a cell as I did.(i.e. Book1.xls)
Set DestWB = Workbooks(Wrkbk)

For Each ws In ThisWorkbook.Worksheets
With DestWB.Worksheets
ws.Copy after:=.Item(.Count)
Next ws

Linkage (LinkPath) 'This will change the link
ActiveWorkbook.Save
Windows(Mastr).Activate
End Sub

Function Linkage(link1 As String)
'Undo the links to the Master file and set to current book
ActiveWorkbook.ChangeLink link1, ActiveWorkbook.FullName, xlExcelLinks
End Function

"mydogpeanut" wrote:

Hello,

I want to write a macro that takes certain tabs of a workbook and copies
them to a new workbook then breaks all links in the newly created workbook.

Can this be done?

If so what would the VBA look like?

Thanks so much :)

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 and Past Macro J.W. Aldridge Excel Programming 3 September 21st 07 10:18 PM
Macro to copy and past a new row when the a row is filled in. lookLikeWorks Excel Programming 1 July 29th 07 10:36 PM
Macro: Insert, copy and past data from sheet Metaldream7 Excel Discussion (Misc queries) 0 November 8th 06 09:31 PM
Copy Past with macro Murat D. Hekimošlu Excel Programming 1 May 24th 05 02:00 PM
Macro to copy and past selected rows only... Jules[_4_] Excel Programming 1 April 14th 04 02:31 PM


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