I have a routine that is copying various sheets from many workbooks and pasting these sheets in what I am calling a 'master' workbook (which contains the different sheets from the different workbooks).
The code works well, however it is also keeping a reference to the original sheet with the usual 'extra' for example =SUM([Book1]Sheet1!C13:G13)
(to keep the example simple).
The worksheets I am copying need to be copied in the exact same formatting where I am using the following command:
Dim WS_Count As Integer
WS_Count = wb.Worksheets.Count
For c = 1 To WS_Count
If wb.Sheets(c).Name <> "TEST" Then
wb.Sheets(c).Copy Before:=master.Worksheets(master.Sheets.Count)
End If
Next
The Copying and merging of documents works very well however as I am also copying some summary sheets from the workbooks, these contain internal reference to sheets and I am encountering difficulties in copying without the original workbook reference [Book1]. I would not know the file name of the workbook while I am working on the master workbook because there are many source workbook documents.
My question is, Is there a way to copy a sheet with all of its formatting without copying the cell workbook reference?
I have also tried all variations of Paste / Paste Special however this either loses the worksheet formatting or still retains the other workbook reference.
I wish to avoid having to find and replace any string that contains [... .xls] as its not an elegant solution. Any pointers in the right direction would be appreciated.
targetRange.PasteSpecial xlPasteFormats targetRange.PasteSpecial xlPasteValues