
September 5th, 2003, 04:25 AM
|
 |
Gogga
|
|
Join Date: Jul 2003
Posts: 198
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
I'm assuming that you're talking abt a text file.
This can be done in one of two ways: File handling (very much like you'll do it pascal)
Code:
Sub Macro1()
Dim oFso
Dim oFile
Dim oText
Dim iRow
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFile = oFso.GetFile("C:\test.txt")
Set oText = oFile.OpenAsTextStream(1)
iRow = 1
s = oText.readline
While oText.AtEndOfStream <> True
Cells(iRow, 1).Value = s
iRow = iRow + 1
s = oText.readline
Wend
oText.Close
Set oText = Nothing
Set oFile = Nothing
Set oFso = Nothing
End Sub
or you can open the text file as an excel file, and copy and paste the data into column A (I recorded this macro, 2 get the code)
Code:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 2003/09/04
ChDir "C:\"
Workbooks.OpenText Filename:="C:\Test.txt", Origin:=xlWindows, StartRow:= _
1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Columns("A:A").Select
Selection.Copy
Windows("Book2").Activate
ActiveSheet.Paste
End Sub
|