DynamiteHack
Board Regular
- Joined
- Jan 14, 2012
- Messages
- 60
I have worked pretty hard to come up with a solution that does what I had hoped but, it is SLOOOOOW!! Just under 28,000 rows of 8 columns took 19 minutes to process. Not acceptable! LOL!
I am summarizing an application log. The process cycle creates three log lines per complete transaction. The second log line varies depending on if there was an error generated during processing. I have created an array (arrprocID) combining all of the information that I need from those three lines into one line.
The block of code below, slices and dices the array line and deposits the parts into the proper cell in the active row.
I am looking for a better approach to minimize processing time. My brute force programming skills leave a little to be desired!
Should I create arrays of pieces and then assign them to the table row? Is it the slicing and dicing that is so slow? Your thoughts and ideas are welcome!!
Thanks, DH
I am summarizing an application log. The process cycle creates three log lines per complete transaction. The second log line varies depending on if there was an error generated during processing. I have created an array (arrprocID) combining all of the information that I need from those three lines into one line.
The block of code below, slices and dices the array line and deposits the parts into the proper cell in the active row.
I am looking for a better approach to minimize processing time. My brute force programming skills leave a little to be desired!
Should I create arrays of pieces and then assign them to the table row? Is it the slicing and dicing that is so slow? Your thoughts and ideas are welcome!!
Thanks, DH
Code:
Dim ws As Worksheet
Dim tbl As TableObject
Dim tblMain As ListObject
Dim newRecord As ListObject
Dim lastRow As Range
Dim x As Long
Dim ltError As Long 'text splicing tools
Dim rtError As Long
Dim ltTime As Long
Dim rtTime As Long
Dim ltCon As Long
Dim value As Variant
Dim procIDCheck As String
Set ws = Worksheets("Sheet1")
ws.Activate
ws.ListObjects("tblMain").ListRows.Add
Set newRecord = ws.ListObjects("tblMain")
Set lastRow = newRecord.ListRows(newRecord.ListRows.Count).Range
With lastRow
x = 1
'populating table and updating counters
For Each value In arrProcID
.Cells(x, 1) = Left(value, 3)
.Cells(x, 2) = Mid(value, 5, procIDLen)
.Cells(x, 8) = x
If InStr(1, value, "False") > 0 Then
'Debug.Print value
.Cells(x, 3) = UCase(False)
Else
'Debug.Print value
.Cells(x, 3) = UCase(True)
End If
If InStr(1, value, "ERROR") > 0 Then
'Debug.Print value
ltError = InStr(1, value, ",Exception=") + 11
rtError = InStrRev(value, "Updating") - 2
.Cells(x, 6) = Mid(value, ltError, Application.WorksheetFunction.Sum(rtError - ltError))
ActiveCell.WrapText = False
Else
ltTime = InStr(1, value, "Time ")
rtTime = InStrRev(value, "Updating") - 2
ltCon = InStr(1, value, "Confidence") + 11
.Cells(x, 4) = Mid(value, ltCon, 2)
.Cells(x, 5) = Mid(value, ltTime + 5, 6)
End If
x = x + 1
Next
End With