I built someone a piece of code that looks through their very old txt files that do not convert to excel very well. I go through the file looking for key words, so in the end they have a nice spreadsheet that has a large table of data, everything aligned and neat.
The code however takes over 5 minutes. I am not sure if it is appropriate to even ask, but if there is anything that sticks out that you think I could improve, I am all ears. I describe the routines here, and I won't post all of the code. My methods are novice and simple and could definitely use some cleaning up I know.
Sub CountSon = this is the main routine that runs and populates the table. In it many other subroutines are called and ran on loops.
For CountSon, I also posted one of the subroutines, for example, NewFindINV. The other routines in CountSon are very similar to NewFindINV.
NewFindINV
The code however takes over 5 minutes. I am not sure if it is appropriate to even ask, but if there is anything that sticks out that you think I could improve, I am all ears. I describe the routines here, and I won't post all of the code. My methods are novice and simple and could definitely use some cleaning up I know.
Sub CountSon = this is the main routine that runs and populates the table. In it many other subroutines are called and ran on loops.
For CountSon, I also posted one of the subroutines, for example, NewFindINV. The other routines in CountSon are very similar to NewFindINV.
Code:
Sub CountSon()
Application.ScreenUpdating = False
FindIVZ
Columns("A:A").Select
Range("A900000").End(xlUp).Select
LastCell = Selection.Row
ival = Application.WorksheetFunction.CountIf(Range("A1:A" & LastCell), "*Invoice #*")
Range("A1").Select
Range("A1").Select
For i = 1 To ival
NewFindINV
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
Writer
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
Address
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
ShipDt
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
ShipVia
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
ShipINST
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
ST
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
Tax
Next i
FindIVZ
Range("A1").Select
For i = 1 To ival
Freight
Next i
Clean
Application.ScreenUpdating = True
End Sub
NewFindINV
Code:
Sub NewFindINV()
Dim Num As String
FindIVZ
Cells.Find(What:="Invoice #", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Num = Left(ActiveCell, 22)
Sheets("Totals").Select
Range("A900000").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = Num
End Sub