import tekst >65536 rows

R

Reniek

Hi,

If I have a txt file with data more than 65536 rows, is it possible to
import into Excell all the data divided into 2 sheets or the part will be
lost?

Thanks for any advice
IW
 
G

Guest

Hi Reniek,

This is possible. Try the following code:

Sub test()

Dim currline As String
Dim counter As Long


counter = 1

Open "c:\Transaction.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, currline

If counter > 65536 Then
Sheets("sheet2").Select
End If

Cells(counter, 1) = currline
counter = counter + 1
Loop




End Sub

Replace "C:\Transation.txt" with your file. As you run out of rows on the
current sheet, it will spill over into sheet2. You can repeat for as many
sheets as you like.

Regards

Ashley
http://vbanut.blogspot.com
 
G

Guest

Reniek

Noticed an error in my code. You also need to reset the counter once you
move onto the next sheet:
 
J

Jim Cone

Tom,

Well I started out to reference 119770, but it somehow didn't end up that way. <g>

Thanks for being more alert than I am today.

Regards,
Jim Cone
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top