ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trying to NOT import some records in a large text file (https://www.excelbanter.com/excel-programming/417794-trying-not-import-some-records-large-text-file.html)

Francois via OfficeKB.com

Trying to NOT import some records in a large text file
 
Hi All,

I'm importing a large text file into Excel.(I have no control of the format
at source).

I'm trying to NOT import any records that start with AAJ and accept all
others, but I can't get the code to do what I'm trying to tell it.


Do until EOF(FNum)

Line Input #FNum,Inputline

'These are the lines that I want to NOT import
If Left(InputLine(,3)="AAJ" Then (How do I tell it to miss this record and
get the next one?)




loads more code here



Loop

Thanks in advance for any help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


incre-d[_2_]

Trying to NOT import some records in a large text file
 
Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd

lots of code


ContinueFromEnd
Loop


"Francois via OfficeKB.com" wrote:

Hi All,

I'm importing a large text file into Excel.(I have no control of the format
at source).

I'm trying to NOT import any records that start with AAJ and accept all
others, but I can't get the code to do what I'm trying to tell it.


Do until EOF(FNum)

Line Input #FNum,Inputline

'These are the lines that I want to NOT import
If Left(InputLine(,3)="AAJ" Then (How do I tell it to miss this record and
get the next one?)




loads more code here



Loop

Thanks in advance for any help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1



incre-d[_2_]

Trying to NOT import some records in a large text file
 
Should read

Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd

lots of code


ContinueFromEnd: '<---- Colon at end
Loop


"incre-d" wrote:

Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd

lots of code


ContinueFromEnd
Loop


"Francois via OfficeKB.com" wrote:

Hi All,

I'm importing a large text file into Excel.(I have no control of the format
at source).

I'm trying to NOT import any records that start with AAJ and accept all
others, but I can't get the code to do what I'm trying to tell it.


Do until EOF(FNum)

Line Input #FNum,Inputline

'These are the lines that I want to NOT import
If Left(InputLine(,3)="AAJ" Then (How do I tell it to miss this record and
get the next one?)




loads more code here



Loop

Thanks in advance for any help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1



Dave Peterson

Trying to NOT import some records in a large text file
 
I would just use the else branch:

Do until EOF(FNum)

Line Input #FNum,Inputline
If ucase(Left(InputLine,3)) ="AAJ" Then
'do nothing
else
'your code to import that line here
end if

loop



"Francois via OfficeKB.com" wrote:

Hi All,

I'm importing a large text file into Excel.(I have no control of the format
at source).

I'm trying to NOT import any records that start with AAJ and accept all
others, but I can't get the code to do what I'm trying to tell it.

Do until EOF(FNum)

Line Input #FNum,Inputline

'These are the lines that I want to NOT import
If Left(InputLine(,3)="AAJ" Then (How do I tell it to miss this record and
get the next one?)

loads more code here

Loop

Thanks in advance for any help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


--

Dave Peterson

Francois via OfficeKB.com

Trying to NOT import some records in a large text file
 
Hi incre-d,

Thanks for the quick reply, I tried this (I took out the GOTO bit, but it
still imported the AAJ line.

I assume the ContinueFromEnd is an empty sub routine.

Any Idea where I might be going wrong Thanks again

incre-d wrote:
Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd

lots of code

ContinueFromEnd
Loop

Hi All,

[quoted text clipped - 17 lines]

Thanks in advance for any help


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


Francois via OfficeKB.com

Trying to NOT import some records in a large text file
 
Dave Peterson wrote:
I would just use the else branch:

Do until EOF(FNum)

Line Input #FNum,Inputline
If ucase(Left(InputLine,3)) ="AAJ" Then
'do nothing
else
'your code to import that line here
end if

loop


I must be doing something wrong.
Here's a section of the code I'm using ( It's from that nice Chip Pearson)


''''''''''''''''''''''''''''''''''''''''''''''
' Loop until we hit the end of the file.
''''''''''''''''''''''''''''''''''''''''''''''
On Error GoTo 0
Do Until EOF(FNum)
''''''''''''''''''''''''''''''''''''''''''''''
' Get the next line of data from the file
''''''''''''''''''''''''''''''''''''''''''''''
Line Input #FNum, InputLine

If UCase(Left(InputLine, 3)) = "AAJ" Then



Else
End If

''''''''''''''''''''''''''''''''''''''''''
' Increment counters.
''''''''''''''''''''''''''''''''''''''''''
InputCounter = InputCounter + 1
RowsThisSheet = RowsThisSheet + 1


But it still imports the records that I don't want



[quoted text clipped - 21 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1



--
Message posted via http://www.officekb.com


Dave Peterson

Trying to NOT import some records in a large text file
 

Do Until EOF(FNum)
''''''''''''''''''''''''''''''''''''''''''''''
' Get the next line of data from the file
''''''''''''''''''''''''''''''''''''''''''''''
Line Input #FNum, InputLine

If UCase(Left(InputLine, 3)) = "AAJ" Then
'do nothing
Else
''''''''''''''''''''''''''''''''''''''''''
' Increment counters.
''''''''''''''''''''''''''''''''''''''''''
InputCounter = InputCounter + 1
RowsThisSheet = RowsThisSheet + 1
'more code that does the real work
End If
loop


"Francois via OfficeKB.com" wrote:

Dave Peterson wrote:
I would just use the else branch:

Do until EOF(FNum)

Line Input #FNum,Inputline
If ucase(Left(InputLine,3)) ="AAJ" Then
'do nothing
else
'your code to import that line here
end if

loop


I must be doing something wrong.
Here's a section of the code I'm using ( It's from that nice Chip Pearson)

''''''''''''''''''''''''''''''''''''''''''''''
' Loop until we hit the end of the file.
''''''''''''''''''''''''''''''''''''''''''''''
On Error GoTo 0
Do Until EOF(FNum)
''''''''''''''''''''''''''''''''''''''''''''''
' Get the next line of data from the file
''''''''''''''''''''''''''''''''''''''''''''''
Line Input #FNum, InputLine

If UCase(Left(InputLine, 3)) = "AAJ" Then



Else
End If

''''''''''''''''''''''''''''''''''''''''''
' Increment counters.
''''''''''''''''''''''''''''''''''''''''''
InputCounter = InputCounter + 1
RowsThisSheet = RowsThisSheet + 1

But it still imports the records that I don't want



[quoted text clipped - 21 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1



--
Message posted via http://www.officekb.com


--

Dave Peterson

Dave Peterson

Trying to NOT import some records in a large text file
 
It's not a subroutine--it's a label that's used for branching.

Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd:

''''''''''''''''''''''''''''''''''''''''''
' Increment counters.
''''''''''''''''''''''''''''''''''''''''''
InputCounter = InputCounter + 1
RowsThisSheet = RowsThisSheet + 1
'more code that does real stuff

ContinueFromEnd:
Loop


=======
I like the if/then/else structure better.

"Francois via OfficeKB.com" wrote:

Hi incre-d,

Thanks for the quick reply, I tried this (I took out the GOTO bit, but it
still imported the AAJ line.

I assume the ContinueFromEnd is an empty sub routine.

Any Idea where I might be going wrong Thanks again

incre-d wrote:
Do Until EOF(fNum)

If (Left(inputline, 3) = "AAJ") Then GoTo ContinueFromEnd

lots of code

ContinueFromEnd
Loop

Hi All,

[quoted text clipped - 17 lines]

Thanks in advance for any help


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


--

Dave Peterson

Francois via OfficeKB.com

Trying to NOT import some records in a large text file
 
Success, Thanks Dave.




Dave Peterson wrote:
Do Until EOF(FNum)
''''''''''''''''''''''''''''''''''''''''''''''
' Get the next line of data from the file
''''''''''''''''''''''''''''''''''''''''''''''
Line Input #FNum, InputLine

If UCase(Left(InputLine, 3)) = "AAJ" Then
'do nothing
Else
''''''''''''''''''''''''''''''''''''''''''
' Increment counters.
''''''''''''''''''''''''''''''''''''''''''
InputCounter = InputCounter + 1
RowsThisSheet = RowsThisSheet + 1
'more code that does the real work
End If
loop


I would just use the else branch:

[quoted text clipped - 41 lines]
--
Message posted via http://www.officekb.com



--
Message posted via http://www.officekb.com



All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com