Out of Memory Redim Array VBA

时间:2015-01-14 23:13:07

标签: vba excel-vba excel-2010 excel

我有以下代码块,它们在指定范围内搜索文本限定符和句点(点)。如果找到这些,将突出显示。如果数据集很小,代码运行正常,但如果文件很大,则会遇到问题。我用55000行测试了一段时间,它给了我一个"内存不足"错误。有没有办法解决?谢谢!

    'Check for extra text qualifiers and if there are periods
    Keywords = Array(Chr(34), "'", ",")
    CodeKeyword = Array(".")
    lastrow2 = ThisWorkbook.Worksheets("File").Range("A" & Rows.Count).End(xlUp).Row
    Set SearchRange = ThisWorkbook.Sheets("File").Range("A1:BH" & lastrow2)
    Set SearchRangeCode = ThisWorkbook.Sheets("File").Range("O2:AM" & lastrow2)
    iRange_Col = SearchRange.Columns.Count
    iRange_Row = SearchRange.Rows.Count
    iRangeCode_Col = SearchRangeCode.Columns.Count
    iRangeCode_Row = SearchRangeCode.Rows.Count
    ReDim vArray(1 To iRange_Row, 1 To iRange_Col)
    ReDim vArrayCode(1 To iRangeCode_Row, 1 To iRangeCode_Col)
    vArray = SearchRange
    vArrayCode = SearchRangeCode

0 个答案:

没有答案