Dear experts,
I am desperately looking for your help. I have a code (below simplified) with around 20 "checks" that need to be done per each line found in the excel worksheet. The problem is that each ''check'' can have different results, therefore I am doubting whether an array would work. I believe the code is slow due to interaction with the worksheet (writing back each cell separately).
Below is a very simplified portion of what I try to do. In reality I loop over 100k rows with 20 criteria to be written in different columns.
Is there any way to speed this up?
Thank you very much for you kind help!
Bundi
![]()
Sub Problem() Dim wsProblem As Worksheet Dim i As Long Dim element As String Dim Arr() As Variant i = 5 With ws.Problem 'Start Loop Do While Not (IsEmpty(.Cells(i, 1))) ReDim Arr(1 To 2) element = .Cells(i, 5) 'Criteria 1 If IsNumeric(Mid(element, 4, 1)) Then Arr(1) = 3 End If 'Criteria 2 If Len(element) <> 8 And Mid(element, 3, 1) = 8 Then Arr(2) = 7 Else Arr(2) = 9 End If i = i + 1 'Write values Range(.Cells(i, 12), .Cells(i, 12)).Resize(LBound(Arr, 1), UBound(Arr, 1)).Value = Arr Loop End Sub 'End Sub
Bookmarks