Copy column groupings

P

Paul Martin

I've written some code that rebuilds each worksheet in the workbook.
I'm wondering how to ascertain whether a given sheet has any column
groupings and then copy them to the new sheet. Any suggestions are
appreciated.

Thanks in advance

Paul Martin
Melbourne, Australia
 
A

Atishoo

Forgive my feeble brain! Im not entirely sure what you mean by Column
Groupings, are you asking for a change to the code your currently using to
rebuild wour worksheets or a fresh piece of code to copy data between sheets
if certain criteria are met?
 
P

Paul Martin

Thanks for the response, Atishoo. I'm referring to (in Excel 2003)
Data, Group and Outline, Group to group columns. Where this has
occurred on a sheet, I want to be able to detect it in code and then
copy it to another sheet.
 
D

Dave Peterson

I think you'll have to look for that outlinelevel:

Option Explicit
Sub testme99()
Dim myRange As Range
Dim myCell As Range
Dim maxLevel As Long

With ActiveSheet
Set myRange = .Rows(1)

maxLevel = 0
For Each myCell In myRange.Cells
If myCell.EntireColumn.OutlineLevel > maxLevel Then
maxLevel = myCell.EntireColumn.OutlineLevel
End If
Next myCell

End With
MsgBox "Largest visible level: " & maxLevel

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top