首页 文章

找到具有specfic值的单元格并删除其下方的选定数组

提问于
浏览
-4

我有一个跨越 BL3:CW10000 的公式数组,它使用字母数字字符串的综合列表(长度在1000-2000个条目之内) . 计算完成后,结果值将复制到另一个工作表 . 我试图在两个选项之间做出决定:

  • 让公式的数组“固定”,每个单元格下载到第10000行,然后删除#REF!复制/粘贴值产生的结果(此数组是问题 Headers 所指的) .

  • 让VBA将其指定列中的每个单独公式自动填充到合并列表范围中条目数指定的长度 . 哪种速度最好?

1 回答

  • 0

    我需要很长时间才能设置自己的示例数据和代码来测试任一选项的时间;但是(假设您已经获得了两个选项的代码),在您的结尾获取该信息应该相当简单 .

    创建一个调用子(见下文),打开即时窗口,然后运行调用子查看结果 .

    Sub Timer_Test()
    
        Dim dTime as Double
    
        dTime = Timer
    
        Call Relevant_Sub_or_Function_One
    
        Debug.Print "descriptive text (method One)" & Timer - dTime
        dTime = Timer
    
        Call Relevant_Sub_or_Function_Two
    
        Debug.Print "descriptive text (method Two)" & Timer - dTime
    
    End Sub
    

    如果两种方法运行得太快而结果没有帮助,请设置如下所示的循环 . (注意:如果方法需要一段时间,你应该从一个较小的循环数开始,比如100左右,并根据需要进行构建)

    Sub Timer_Test()
        Dim counter as Long
        Dim dTime as Double
    
        dTime = Timer
    
        For counter = 1 to 10000 ' Or whatever value you deem appropriate...
            Call Relevant_Sub_or_Function_One
            DoEvents 'optional, keeps Excel from crashing, but you shouldn't attempt to use Excel while this is running, or the results will be skewed...
        Next counter
    
        Debug.Print "descriptive text (method One)" & Timer - dTime
        dTime = Timer
    
        For counter = 1 to 10000 ' Or whatever value you deem appropriate...
            Call Relevant_Sub_or_Function_Two
            DoEvents 'optional, keeps Excel from crashing, but you shouldn't attempt to use Excel while this is running, or the results will be skewed...
        Next counter
    
        Debug.Print "descriptive text (method Two)" & Timer - dTime
    
    End Sub
    

相关问题