()将文本中指定行写入已有EXCEL文件指定列

(请教高手)将文本中指定行写入已有EXCEL文件指定列本来已经请教过了,但是当时没有把问题说清楚,现在再请教

(请教高手)将文本中指定行写入已有EXCEL文件指定列
本来已经请教过了,但是当时没有把问题说清楚,现在再请教各位高手。    
我想将文本数据的指定行转换成列,写入已经存在的EXCEL的指定列。先谢谢

[解决办法]
'以下读出了文本文件所有行的内容
dim file1,i,j as integer
dim filename,temp() as string
i=1
filename= "c:\test.txt " '要打开的文本文件
open filename for input as file
do while not eof(file1)
line input #file1,temp(i) '整行读出,存入temp中
i=i+1
loop
close file1
' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
'以下把文本文件写入EXCEL列中
dim exlApp As Excel.Application 'EXCEL表格
dim exlBook As Excel.Workbook '工作簿
dim exlSheet As Excel.Worksheet '工作表
dim exlFilename as string '要写入的EXCEL文件名
exlfilename= "c:\test.xls "
Set exlApp = New Excel.Application
exlApp.Visible = False '不可见
Set exlBook = exlApp.Workbooks.Open(exlfilename)
Set exlSheet = exlBook.Worksheets(1)
for j=1 to i
exlsheet.cells(1,j)=temp(j) '(行,列)
next j
exlbook.save
exlbook.close
exlapp.quit
set exlsheet=nothing
set exlbook=nothing
set exlapp=nothing

[解决办法]
哦,上一贴是我回复的。其实你在上次代码的基础上修改一下就可以了,方法有许多,我还是修改一下上次的代码,希望你能读明白:

   '读出文本内容
Dim pFile As String
Dim hFile As Integer
Dim sFile As String

pFile = "C:\test.txt "
hFile = FreeFile()

Open pFile For Binary As hFile
sFile = Space(LOF(hFile))
Get hFile, , sFile
Close hFile

'处理读取的数据:
Dim fLines() As String
Dim sRows() As String
Dim sExcel() As String '插入Excel的内容
Dim i As Integer
Dim row As Integer

fLines = Split(sFile, vbCrLf) '按vbCrLf分组,得到行数据
'比如指定第10行:
sRows = Split(fLines(9), Chr(32))
ReDim sExcel(UBound(sRows), 0)
For i = 0 To UBound(sRows)
If Trim(sRows(i)) <> " " Then
sExcel(row, 0) = sRows(i)
row = row + 1
End If
Next i

'导入Excel
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

Set oExcel = CreateObject( "Excel.Application ")
Set oBook = oExcel.Workbooks.open( "C:\test.xls ")
Set oSheet = oBook.Worksheets(1)
'指定插入G列
oSheet.Range( "G1 ").Resize(row, 1).Value = sExcel
oExcel.Visible = True

Set oSheet = Nothing
Set oBook = Nothing
oExcel.Quit
Set oExcel = Nothing