saulodefaria
New Member
- Joined
- Jul 8, 2014
- Messages
- 3
Hi guys!
Here's my problem: I have some huge txt files (~700k lines) with csv data from stock prices. One of the columns is the name of the company. So I want to get only the lines of certain companies. I actually already have a solution, but it is taking too much time. I think it may take hours to filter just one txt file, but I have lots of them...
Here's the code I'm using now:
It does the job. But I was hoping I could get some ideas to do it faster.
Thanks!
Here's my problem: I have some huge txt files (~700k lines) with csv data from stock prices. One of the columns is the name of the company. So I want to get only the lines of certain companies. I actually already have a solution, but it is taking too much time. I think it may take hours to filter just one txt file, but I have lots of them...
Here's the code I'm using now:
Code:
Sub delete()
Dim dontDelete
dontDelete = Array("APPLE", "MICROSOFT", "GOOGLE")
Dim i As Long, j As Long
Dim isThere As Boolean
For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
For j = LBound(dontDelete) To UBound(dontDelete)
If InStr(1, Range("A" & i), dontDelete(j)) Then
isThere = True
End If
Next j
If Not isThere Then
Range("A" & i).delete shift:=xlUp
End If
isThere = False
Next i
End Sub
It does the job. But I was hoping I could get some ideas to do it faster.
Thanks!