Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 919
- Office Version
- 365
- Platform
- Windows
I have a code that works "perfectly". It writes 350 000 rows into a text file. I want to let user know what is happening so I use application.statusbar with a mod operation, like this:
The problem is that after a while Excel "chokes" and while it does what I want it to do, user gets a pretty clear signal that it crashed. What's the recommended way to let Excel catch it's breath so that even if the code would run slightly slower, I could keep user updated of the process instead of this legendary "The program is not responding"-status?
Code:
For L = LBound(vCards, 1) + 1 To UBound(vCards, 1) 'Skip header row
strCard = L & vbTab & vCards(L, 2) & vbTab & vCards(L, 3) & vbTab & vCards(L, 4) & vbTab & vCards(L, 5) & vbTab & vCards(L, 6) & vbTab & vCards(L, 7) & vbTab & vCards(L, 8) & vbTab & vCards(L, 9) & vbTab & vCards(L, 10) & vbTab & vCards(L, 10) & vbTab & vCards(L, 11) & vbTab & vCards(L, 12) & vbTab & vCards(L, 13)
If L Mod 10000 = 0 Then
Application.StatusBar = "Creating temporary textfile for uploading, " & L & " of " & UBound(vCards, 1) & " cards processed"
End If
Print #lProductFile, strCard
Next L
The problem is that after a while Excel "chokes" and while it does what I want it to do, user gets a pretty clear signal that it crashed. What's the recommended way to let Excel catch it's breath so that even if the code would run slightly slower, I could keep user updated of the process instead of this legendary "The program is not responding"-status?