我正在尝试使用Excel VBA宏来使用搜索框过滤列表。
以下是我使用的代码:
from decimal import Decimal, getcontext
getcontext().prec = 4
def main():
myfile = open('Phrases Compiled.txt', 'w')
NumTrials = 0
SumLength = 0
StoreLengths = dict()
response = input("are there more calculations you'd like to do?")
while response != "no":
if response in ['yes', 'y', 'Yes', 'Y']:
start, stop = eval(input("what is the start and stop times of the phrase?"))
start = Decimal(start)
stop = Decimal(stop)
length = stop - start
StoreLengths[NumTrials] = length
NumTrials += 1
SumLength += length
print(length)
length = str(length)
NumTrials = str(NumTrials)
myfile.write("the length of phrase #", NumTrials, "is: ", length + "\n") # Note that it's length + "\n"
response = input("are there more calculations you'd like to do?")
elif response in ['no', 'n', 'N', 'No']:
print("calculations are done")
break
averagelength = SumLength/NumTrials
print("average length was:", averagelength)
当我使用F8单步执行代码时,我收到一条错误消息,指出单元格D $ 23 $中的标题名称“Area”未找到,实际上我确实在单元格D23中写了区域。