我正在使用' Worksheet_Change'每次用户在下拉列表中选择由于访问大数据范围的选项时,宏中的事件大约需要15-20秒。我想在Excel中显示一个非常基本的%完成状态,让用户知道它正在处理。使用默认的Excel Application.StatusBar就足够了,但它在我的工作簿上不可见。
我的工作隐藏/显示列宏:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R, V
If Target.Address = ("$K$7") Then
V = [K7].Value
For Each R In Range("R3:GJU3")
If IsError(R.Value) Then
R.EntireColumn.Hidden = True
Else
R.EntireColumn.Hidden = R.Value <> V
End If
Next
End If
End Sub
我在单独的帖子中找到了下面的代码,但我不确定如何根据我上面的宏修改我的目的。
以下代码兑换@eykanalOption Explicit
Sub StatusBar()
Dim x As Integer
Dim MyTimer As Double
'Change this loop as needed.
For x = 1 To 250
'Dummy Loop here just to waste time.
'Replace this loop with your actual code.
MyTimer = Timer
Do
Loop While Timer - MyTimer < 0.03
Application.StatusBar = "Progress: " & x & " of 250: " & Format(x / 250, "Percent")
DoEvents
Next x
Application.StatusBar = False
End Sub
答案 0 :(得分:0)
按如下所示更新您的代码
from multiprocessing.dummy import Pool as ThreadPool
class Mass:
def __init__(self):
self.pool = ThreadPool(4)
def calcForceFrom(self, p_mass):
forces = self.pool.map(p_mass.calcForceOn, self.elements)
F_total = sum(forces)
答案 1 :(得分:0)