LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Import partial record from text file string

Sub Import_Test()
Dim datafile$
Dim a1 As string
Dim sRow as Long

datafile$ = "C:\emory_fv\emory_fv.txt"
On Error GoTo DiskError

Open datafile$ For Input As #1

Sheet1.Activate
With Range("A1")
Do While Not EOF(1)
Line Input #1, a1
srow = srow + 1
.Offset(srow, 0).value = left(a1,9)
Loop
End With
Close #1

Exit Sub

DiskError:
a = MsgBox("Disk Error." & Err.Number, vbExclamation)

End Sub

--
Regards,
tom Ogilvy

"goss" wrote in message
...

Hi ng.
Using xl 2003

I need to import first 9 chars from every line in text file and output
beginning at
A2 and down til EOF of text file.

Current file has 9500 lines, but will vary weekly

Here's my current code:

Sub Import_Test()
Dim datafile$
Dim a1 As String * 9


datafile$ = "C:\emory_fv\emory_fv.txt"
On Error GoTo DiskError

Open datafile$ For Input As #1

Sheet1.Activate
With Range("A1")
Do While Not EOF(1)
Input #1, a1
Offset(srow, 0) = a1
srow = srow + 1
Loop
End With
Close #1

Exit Sub

DiskError:
a = MsgBox("Disk Error." & Err.Number, vbExclamation)

End Sub


--
goss


------------------------------------------------------------------------
goss's Profile:

http://www.excelforum.com/member.php...fo&userid=4602
View this thread: http://www.excelforum.com/showthread...hreadid=278899



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count partial matched text string Chapi New Users to Excel 5 July 5th 10 06:34 AM
auto bold partial text in a string dave in Toronto Excel Discussion (Misc queries) 1 June 12th 07 01:07 PM
Import txt file with multiple rows for each record VanessaNY Excel Discussion (Misc queries) 4 September 15th 05 07:33 PM
How to import a text file to Excel treating all input content are in string. Chittu Excel Discussion (Misc queries) 1 July 22nd 05 06:37 AM
searching a string with a partial string dcstech Excel Programming 1 April 5th 04 10:57 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"