0

I have a spreadsheet of about 20,000 rows. This spreadsheet is a hierarchy that displays part lists for pieces of equipment. I have created code that creates buttons (actually the shape rectangle) that allow the user to expand / contract these groups through hiding / unhiding rows.

I believe the code is running slow because there are several thousand buttons on the spreadsheet that I believe are refreshing each time rows are hidden. When I click the button the code runs, the correct rows hide / unhide, then all the buttons dissapear for a few seconds then reapear. The disapearing occurs after the rows hide or unhide so the code has already finnished running.

Is there any way to stop Excel from refreshing every button? Is there a different issue?

4

2 回答 2

0

听起来您可以利用 Excel 中的数据透视表功能。我确信它比电子表格使用的宏/按钮快得多:

数据透视表大纲 数据透视表大纲

您只需要努力将数据重新组织成合适的格式。祝你好运。

如果您需要关于数据透视表的解释,您可以谷歌“数据透视表教程 。http://www.google.com/search? q=%22pivot+table+tutorial%22

于 2013-04-19T19:30:04.097 回答
0

我使用了一种解决方法,当代码方便时我会详细说明,但就像这样:

  1. 让您的按钮创建宏在单元格中创建超链接,而不是使用文本+/-和工具提示>>expand/collapse<<

    ActiveSheet.Hyperlinks.Add _
        Anchor:=[A1], Address:="", _
        SubAddress:=[A1].Address, _
        ScreenTip:=">>expand/collapse<<", _
        TextToDisplay:="+/-"
    
  2. 在这种情况workseet_followhyperlink下,请检查工具提示是否存在>>expand/collapse<<,如果是,请按照您的宏进行播种和隐藏。

    if target.screentip = ">>expand/collapse<<" then 
        myShowHideMacro
    else
        'do other stuff
    end if
    
于 2013-04-21T11:43:59.893 回答