Share via

Naming a Grouped range of columns in a spreadsheet

Anonymous
2014-07-25T00:35:50+00:00

Hi,

Was wonderinf if there was a way of assigning a name or label to a set of Grouped columns in excel?  For example, if i have a small range of columns that relate to fees, and I group these togather, can I assign a label Fees to this, so that when the gropup is minimised, then a label is there that I can click on to open the fees grouped data?

Hope this makes sense :-)

Thanks in advance for your help,

Marcos

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Vijay A. Verma 104.8K Reputation points Volunteer Moderator
    2014-07-25T02:59:23+00:00

    Labeling a group is not possible in Excel. But, in my view, this is a worth-while feature to be asked. I will request you to submit this feedback to Microsoft. Please use following link -

    http://office.microsoft.com/en-gb/suggestions.aspx

    Note - The maximum approximation which you can do it to NAME the group but it will not mimic Labeling which are asking for.

    Let's say, you grouped Columns are A and B. Select Columns A and B and in the Name Box (Left to Formula bar), you can give it a name say Fees.

    So, whenever you will type Fees in Name Box, it will immediately position your cursor there suggesting that this is the group which you need to open.

    But, in this case, person needs to know the names of various groups.

    60+ people found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-07-25T04:02:34+00:00

    Hi,

    Was wonderinf if there was a way of assigning a name or label to a set of Grouped columns in excel?  For example, if i have a small range of columns that relate to fees, and I group these togather, can I assign a label Fees to this, so that when the gropup is minimised, then a label is there that I can click on to open the fees grouped data?

    Hope this makes sense :-)

    Hi Marcos,

    Alt-F11 to open the VBA editor

    Alt-IM to insert a new code module

    In the new module, paste the following code

    '==========>>

    Option Explicit

    '---------->>

    Public Sub ToggleColumns()

        Dim SH As Worksheet

        Dim Rng As Range

        Dim obj As Variant

        Dim BTN As Button

        Dim iLen As Long

        Const myColumns As String = "H:K"               '<<===== Change

        Const sFees As String = "Fees"                       '<<===== Change

        Const sHidden As String = " Hidden"

        Const sVisible As String = " Visible"

        Set SH = ActiveSheet

        Set BTN = SH.Buttons(Application.Caller)

        Set Rng = SH.Columns(myColumns)

        With Rng.EntireColumn

            .Hidden = Not .Hidden

            If .Hidden Then

            iLen = Len(sHidden) + Len(sFees)

                BTN.Characters.Text = sFees & " Hidden"

                With BTN.Characters(Start:=1, Length:=iLen).Font

                    .Name = "Arial"

                    .FontStyle = "Bold"

                    .Size = 10

                    .ColorIndex = 3  '\ RED

                End With

            Else

            iLen = Len(sVisible) + Len(sFees)

            BTN.Characters.Text = sFees & " Visible"

                With BTN.Characters(Start:=1, Length:=iLen).Font

                    .Name = "Arial"

                    .FontStyle = "Bold"

                    .Size = 10

                    .ColorIndex = 4  '\ GREEN

                End With

            End If

        End With

    End Sub

    '<<==========

    Alt-Q to close the VBA editor

    Place  a button from the forms toolbox onto the worksheet and assign the macro to the button:

    Now, clicking the button will alternately hide and unhide the fees columns and the button's caption will alternately show Fees Hidden in red orFees Visiblein green**.** Thus, the button caption will act in lieu of your label and you will have the desired functionality.

    ===

    Regards,

    Norman

    10+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2017-09-11T15:38:04+00:00

    Hi Norman,

    I am trying to apply the same grouping principle to Rows rather than columns, can you assist with the alternate code to create the hide/unhide button please?

    Many Thanks

    3 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2014-07-25T03:06:30+00:00

    Thanks for your advice Vijay, I'll put that suggestion in :-)

    2 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2015-11-19T16:01:52+00:00

    Hi Norman,

    Your solution works! but only if I need to hide/unhide the columns ("fees") while working elsewhere in the spreadsheet.

    I have groups of 6 columns, per project, that I need to hide and unhide - and they have nothing to do with each other.

    Can I do this, using your solution - hence having the buttons up in the grey area above the column labels (A, B, C...)? 

    So far the only way I've found to do this, was to put all the buttons below one another in an inserted column, A

    Thanks :) 

    Marie

    1 person found this answer helpful.
    0 comments No comments