View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ken Ken is offline
external usenet poster
 
Posts: 207
Default How can I group and display columns automatically?

faraz

This is the technique use; it may be useful to you.

For each verticle group you want, you create range name for an entire
row somewhere below your data. Put a value in the columns that are to
be part of the group, leve the rest blank. In a column that is always
visible, maybe one of your data columns, maybe a new column solely to
identify your row names. Then in the before double-click event for
the worksheet put in this code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

Dim S As String

S = ActiveCell.Value

Range(S).Select

Selection.EntireColumn.Hidden = False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireColumn.Hidden = True

End Sub

You may not want to use the before double-click code to trigger it,
but, the basic idea is you have a row, with non blank values in the
columns you want for your group and the group name visible in a
column. You can add and modify groups by inserting range names for
complete rows without making any VBA changes; which is good if someone
else is adjusting the groups or making up new groups. You can display
the group by double clicking on the group name; or another trigger
action if you prefer.

Good luck

Ken
Nofolk, Va

On Jun 29, 4:21*pm, faraz316
wrote:
I have 40 columns on a worksheet and many rows, and want to set up vertical
groupings i.e. group columns (A, D, G, J ....) together, and then (B, E, H,
K... together), and so on - final result is that all columns can be hidden
and each 'group' can be displayed on its own. I know that rows can be grouped
together using the 'Group' function but am not sure of columns. Does anyone
know if this can be done on Excel?