简体   繁体   English

如何显示内置Excel功能的进度栏?

[英]How can I display a progress bar for a built-in Excel function?

I have an Excel table set up with around 40,000 values that need to be sorted via a userform. 我有一个Excel表格,其中设置了大约40,000个值,需要通过用户表单进行排序。 For this, I used... 为此,我使用了...

myTable.Sort.SortFields.Add Range(strSortBy), xlSortOnValues, xlDescending, xlSortNormal
myTable.Sort.Apply

...where myTable is the table and strSortBy is the header of the column I want to sort by. ...其中myTable是表,而strSortBy是我要作为排序依据的列的标题。

Now, despite Excel's lightning-fast sorting capabilities, with this amount of data it starts taking long enough (several seconds) that I'd like to provide the user with some kind of progress feedback. 现在,尽管Excel具有闪电般的快速排序功能,但由于有了如此大量的数据,它开始花费的时间足够长(几秒钟),因此我想向用户提供某种进度反馈。 I've made several userform progress-bars in Excel, but since Sort is a built-in Excel function, I can't see any obvious ways to show or determine the percentage completed. 我在Excel中制作了几个用户窗体进度栏,但是由于Sort是内置的 Excel函数,因此我看不到任何明显的方式来显示或确定完成百分比。

Is this a lost cause? 这是一个迷失的原因吗? Or is there some way to determine the progress of built-in functions? 还是有某种方法可以确定内置函数的进度?

Any help is greatly appreciated. 任何帮助是极大的赞赏。

I like to use the status bar function, which is built in, to display progress. 我喜欢使用内置的状态栏功能来显示进度。 It is very simple, yet powerful. 它非常简单,但功能强大。

Example: 例:

Application.StatusBar = "Renaming Cells"

While count2 <= (count1)
    DoEvents
    Length = Len(Range("C" & CStr(count2)).Value)
    Newlength = Length - 2
    newID = Left(Range("C" & CStr(count2)).Value, Newlength)
    Range("C" & CStr(count2)).Value = newID
    count2 = count2 + 1
    newID = vbNullString
    Application.StatusBar = "Editing Cell: " & count2 & " of " & count1 & "."
Wend

In the example, I'm able to loop through cells, shortening the length of each one. 在示例中,我可以遍历单元格,缩短每个单元格的长度。 While doing so, I display the cell the program is on, since it can take a long time. 这样做时,我会显示程序所在的单元格,因为这可能需要很长时间。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM