Problems copying/pasting grouped rows and columns

pliskers

Active Member
Joined
Sep 26, 2002
Messages
462
Office Version
  1. 2016
Platform
  1. Windows
I have a macro that inserts a blanks sheet in a workbook, then copies and pastes as values the entire contents of another sheet that has groupings in both rows and columns.

The code (which I did not write) appears below. Can someone have a look and please tell me why the groupings are not properly being copied into the newly inserted sheet? Ideally, I want all values, formats, and column widths to appear exactly the same in the copied worksheet.

Thank you!

Sheets("VPM").Select
Cells.Select
Selection.Copy
Sheets("Geog").Select
Cells.Select
ActiveSheet.Paste
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1

Rows("8:8").Select
Selection.RowHeight = 100
Columns("A:A").Select
Selection.EntireColumn.Hidden = True

ActiveWindow.Zoom = 75
ActiveWindow.DisplayGridlines = False
ActiveWindow.FreezePanes = False
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=4
ActiveSheet.Outline.ShowLevels RowLevels:=2
Range("C12").Select
ActiveWindow.FreezePanes = True
Application.CutCopyMode = False
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
ActiveSheet.Outline.ShowLevels RowLevels:=1
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Just a follow up: I think there may be a problem with the file, which was converted to an xlsm from xls. I know that copy/pasting the formats with the entire sheet highlighted is supposed to work, but when I do that manually, only a handful of the grouped rows appear grouped in the pasted new tab.

I've worked around this by doing two separate copy/pastes of the highlighted rows, then the columns, but this is highly inefficient. Please advise if anyone has encountered a similar issue, or if I'm missing something.

Thanks,
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,818
Members
452,946
Latest member
JoseDavid

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