Moving sheets with merged cells

Andy Clarke

New Member
Joined
Nov 18, 2005
Messages
1
Following the creation of a report on an Excel 2000 sheet, I wish to copy the required sheets only into a new book.

However, the cells may well have over 255 characters.

To get around this (using the cell Sheet1 as an example), the macro copies all worksheets within the workbook (renaming eg. Sheet1 (2)) Then it creates a formula linking back to the original Sheet1. Then the sheets can be moved into a new workbook, with a macro copyandpastevalues (to copy all cells and then paste values) to break the links.

However, the front sheet (Cover) is not automatically generated in the same way as the other sheets, and so may have merged cells across it. (in the region A13:DI34). When I copy within the workbook, these merged cells remain. However, the function .move when the new book is created does not carry the merging over.

It should be noted that when I record this macro manually using the macro recorder, it keeps the merged cells as required, but then when I replay the macro, it does not.

I have not put in a function to go back to the orignial sheet and copy formats and paste, as I do not want to name or specify what these sheets are called.

I am reluctant to go through on the new book and and put the merged cells on, as rows may be inserted, and there are rows 35 to 47 which do not want to be merged, and this will overcomplicate the already complicated macro.

I am moving on soon, so need this to be as idiot-proof as possibe (!), so if anyone can think of an easier way to get around the 255 character problem in a better way, it would be appreciated.

Sub Createreportfile()
Sheets(Array("Cover", "Sheet1")).Copy Before _:=Sheets(10)
Sheets("Cover (2)").Select
Range("A13:DI34").FormulaR1C1 = "=if('Cover'!RC=0,"""",'Cover'!RC)"
Sheets("Sheet1 (2)").Select
Range("A6", ActiveCell.SpecialCells(xlLastCell)).FormulaR1C1 = "=if('Sheet1 '!RC=0,"""",'Sheet1'!RC)"
Sheets(Array("Cover (2)", "Sheet1 (2)")).Select
Sheets("Sheet1 (2)").Activate
Sheets(Array("Cover (2)", "Sheet1 (2)")).Move
Sheets("Cover (2)").Select
CopyandPasteValuesAll
Sheets("Sheet1 (2)").Select
CopyandPasteValuesAll
Application.CutCopyMode = False
Sheets("Cover (2)").Name = "Cover"
Sheets("Sheet1 (2)").Name = "Sheet1"
Sheets("Cover").Select
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,203,600
Messages
6,056,206
Members
444,850
Latest member
dancasta7

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top