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: 52
Default Import Text file Data into Excel Sheet

hey guys i am done with the logic.....


Sub ReadStrings()
Dim sLine As String
Dim sFName As String 'Path and name of text file
Dim iFNumber As Integer 'File number
Dim lRow As Long 'Row number in worksheet
Dim lColumn As Long 'Column number in worksheet
Dim vValues As Variant 'Hold split values
Dim iCount As Integer 'Counter
sFName = "C:\Documents and Settings\vbarlotx\Desktop\Bharath
\AllExcel.csv"

'Get an unused file number
iFNumber = FreeFile
'Prepare file for reading
Open sFName For Input As #iFNumber
Sheet1.Cells.Clear
'First row for data
lRow = 1
Do
'Read data from file
Line Input #iFNumber, sLine
'Split values apart into array
vValues = Split(sLine, ",")
With Sheet2
'First column for data
lColumn = 1
'Process each value in array
For iCount = LBound(vValues) To UBound(vValues)
'Write value to worksheet
..Cells(lRow, lColumn) = vValues(iCount)
'Increase column count
lColumn = lColumn + 1
Next iCount
End With
'Address next row of worksheet
lRow = lRow + 1
'Loop until end of file
Loop Until EOF(iFNumber)
'Close the file
Close #iFNumber
End Sub

 
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
How do a import data from a text file to an excel worksheet madlin Excel Discussion (Misc queries) 4 January 12th 10 04:04 PM
Import Access data to text file rather than Excel Daniel Bonallack Excel Programming 3 May 5th 09 11:51 PM
Import text file into Excel 2007 then copy sheet to another workbo DonnaO Excel Discussion (Misc queries) 2 October 9th 07 07:09 PM
Import data into Excel sheet from CSV File Connie Excel Discussion (Misc queries) 3 November 8th 06 06:02 AM
Import data into Excel sheet from CSV File Connie Excel Programming 3 November 8th 06 06:02 AM


All times are GMT +1. The time now is 06:32 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"