PC Review


Reply
Thread Tools Rate Thread

Copy & Past Macro Question

 
 
=?Utf-8?B?bXlkb2dwZWFudXQ=?=
Guest
Posts: n/a
 
      18th Oct 2007
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 With Quote
 
 
 
 
=?Utf-8?B?SlJGb3Jt?=
Guest
Posts: n/a
 
      18th Oct 2007
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 With Quote
 
=?Utf-8?B?bXlkb2dwZWFudXQ=?=
Guest
Posts: n/a
 
      19th Oct 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed... please (Copy Past Macro) =?Utf-8?B?bXlkb2dwZWFudXQ=?= Microsoft Excel Programming 0 19th Oct 2007 03:17 PM
Copy and Past Macro J.W. Aldridge Microsoft Excel Programming 3 21st Sep 2007 10:18 PM
Macro to copy and past a new row when the a row is filled in. =?Utf-8?B?bG9va0xpa2VXb3Jrcw==?= Microsoft Excel Programming 1 29th Jul 2007 10:36 PM
Copy Past with macro Murat D. Hekimolu Microsoft Excel Programming 1 24th May 2005 02:00 PM
Macro to copy and past selected rows only... =?Utf-8?B?SnVsZXM=?= Microsoft Excel Programming 1 14th Apr 2004 02:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 AM.