I have been researching for a quicker way to do the following task, but I couldn´t...
Can you please help me with that? It is basically a parser that convert text files into sheets, but the problem is that the text file has about 100000 lines and this code is taking more then half hour to run! For each new line of the text file, first I check if the sheet already exists and then check if the column title already exists... if so, it fills the data in the corresponding field, if not it creates the sheet and the column. I know that this code is not optimized at all, but I am not a programmer so that is the way I could make this job. Open sFileName For Input As #1 While Not EOF(1) Line Input #1, sLin If Left(sLin, 3) = "ADD" Or Left(sLin, 3) = "SET" Or Left(sLin, 3) = "MOD" Then sLinSplitted = Split(sLin, ",") NumberOfParameters = UBound(sLinSplitted) For p = 0 To NumberOfParameters Select Case p Case 0 Aux1 = Split(sLinSplitted(p), ":") AuxTabl = Split(Aux1(0), " ") Tabl = AuxTabl(1) Aux2 = Split(Aux1(1), "=") Parm = Aux2(0) Parmval = Aux2(1) If Tabl <> Tablpre Then DoNotCreate = 0 For Each sh In ThisWorkbook.Worksheets If sh.Name = Tabl Then DoNotCreate = 1 GoTo Continue: End If Next If DoNotCreate <> 1 Then ThisWorkbook.Worksheets.Add(After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)).Name = Tabl End If Tablpre = Tabl End If Continue: Linh = ThisWorkbook.Sheets(Tabl).UsedRange.Rows.Count + 1 ThisWorkbook.Sheets(Tabl).Cells(1, 1) = "NE" Case Is > 0 Aux2 = Split(sLinSplitted(p), "=") Parm = Aux2(0) Parmval = Aux2(1) End Select Parm = Replace(Parm, " ", "") Parmval = Replace(Parmval, ";", "") Set Strg = ThisWorkbook.Sheets(Tabl).Range("1:3").Find(Parm, LookAt:=xlWhole) If Strg Is Nothing Then With ThisWorkbook.Sheets(Tabl).Rows("1:1") Set CT = .Find(What:="") End With colun = CT.Column Else colun = Strg.Column End If ThisWorkbook.Sheets(Tabl).Cells(1, colun) = Parm ThisWorkbook.Sheets(Tabl).Cells(Linh, colun) = Parmval Next ThisWorkbook.Sheets(Tabl).Cells(Linh, 1) = NEName If ThisWorkbook.Sheets(Tabl).Cells(2, 1) = "" Then Linh = 2 Else Temp = ThisWorkbook.Sheets(Tabl).UsedRange.Rows.Count Linh = Temp + 1 End If End If Wend Close An example from the input text file is: SET ALMBLKPARA:AID=20031, BLKPRD=0, CNTRISTHRD=0, CNTSTLTHRD=0, TMRISTHRD=0, TMSTLTHRD=0; Where ALMBLKPARA must be the name of the sheet, AID, BLKPRD, CNTRISTHRD, CNTSTLTHRD, TMRISTHRD and TMSTLTHRD the column titles with the corresponding value after each "=". I really appreciate your help. Thanks, Cesar -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.