How to expand a group in Excel by using Hyperlink(or by maybe assigning Macro to Hyperlink)

ぃ、小莉子 提交于 2019-12-02 01:27:22

I'd suggest creating a master sheet with the "group" table and any rollups you need. The subsequent sheets could have all the "section" data on them. This has the added benefit of being more scaleable.

Is it strictly necessary to have all the information on the same sheet? This is pretty much why Excel has multiple sheets. Using multiple sheets would also allow you to use standard hyperlinks.

However, if you would like some VBA to get you closer, consider the code below. This grabs the value form the active cell, then searches for the next cell with that value. If the section with the found cell is collapsed, it expands it and visa versa.

Sub OpenSection()

Dim x As String
x = ActiveCell.Value

Dim y As String
y = Cells.Find(What:=(x), After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Address
'Range("b1").Value = y

With ActiveSheet
    With .Range(y).EntireRow
        If .ShowDetail = False Then
            .ShowDetail = True
        Else
            .ShowDetail = False
        End If
    End With
End With
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!