copy worksheet from one sourceA to sourceB

B

Bob Ford

Hello
I spent hours today trying to figure this out. I am trying to copy a
worksheet from a workbook (contains groupings and subtotals) to another
workbook. It copies it but it does not retain the groupings (drill-down
effect).

The code I used was based from a recorded macro.

Please advise.
TIA!
Bon
 
B

Barb Reinhardt

Have you tried to right click on the worksheet tab and copy it to the other
workbook?
 
G

Gord Dibben

Bob

What method are you using to copy the worksheet?

Right-click on a sheet tab and "move or copy" the entire worksheet?

Or just selecting all cells and copy then paste?

The latter will not retain any data grouping whereas the former will.


Gord Dibben MS Excel MVP
 
B

Bob Ford

I forgot to mention that I need it via VBA code. I know how to idt through
shortcuts and via menu.
 
B

Barb Reinhardt

Let's say you refer to the book you are copying to as aWB and the worksheet
you are copying as oWS. Do this

oWS.Copy After:=aWB.Sheets(aWB.Worksheets.Count)

If you need more assistance, let us know.

HTH,
Barb Reinhardt
 
Top