根据动态条件选择行

时间:2018-12-04 17:24:16

标签: excel vba filter

我的目的是选择与输入框中的条件相对应的行,将其复制并粘贴到另一个工作表中。

代码有效,但我需要填写所有输入框以复制粘贴所需的行。

如果我不填写一个输入框,仍然返回所有符合其他条件的行(例如:如果仅填写“问题”输入框,它将返回具有匹配发布日期的行)。

import time


def MersennePrime(pm=3):
    mp = (2 ** pm) - 1
    print(pm)
    print(mp)
    while pm <=25:
        pm = pm + 1
        print(mp)


def LucasLehmerSequence(n=4):
    lls = (n ** 2) - 2 # Calculates the 2nd digit of the Lucas-Lehmer Sequence.
    print(n)
    print(lls)
    while pm <= 25:
        n = lls
        lls = (n ** 2) - 2
        print(lls)


def Checker(pm=3, n=4):
    start = time.time()
    mp = (2 ** pm) - 1
    while pm <= 25:
        lls = (n ** 2) - 2
        n = lls # Updates the value of n to be = the previous sequence entry.
        lls = (n ** 2) - 2
        pm = pm + 1 # Adds 1 to the power of the Mersenne.
        mp = (2 ** pm) - 1
        if (lls % mp) == 0: # If nth in sequence has a remainder of 0 when / by the nth Mersenne it is a Mersenne Prime.
            print(str(mp) + ' is prime.')
        else:
            print(str(mp) + ' is not prime')
    end = time.time()
    print(end - start)


print(Checker())

0 个答案:

没有答案