use a dataquery to import the text file.
then look at recordcount.
OR use this:
Sub ReadTextStuff()
'Note as is dimmed as string.
'thus any imported data will be imported AS TEXT
Dim h&, cnt&, data() As String
Const FileName = "d:\mytext.txt"
Const maxLines = 50
h = FreeFile
If Dir(FileName) < "" Then
ReDim data(1 To maxLines, 1 To 1)
Open FileName For Input As #h
While Not EOF(h) And cnt < maxLines
cnt = cnt + 1
Line Input #h, data(cnt, 1)
Wend
If Not EOF(h) Then
MsgBox "File is too long"
ElseIf vbYes = MsgBox( _
"Imported " & cnt & " items from " & FileName & _
vbNewLine & "dump in activesheet?", vbYesNo) Then
ActiveSheet.Cells(1).Resize(cnt) = data
End If
Close h
Else
MsgBox "File " & FileName & " not found", vbCritical
End If
End Sub
--
keepITcool
|
www.XLsupport.com | keepITcool chello nl | amsterdam
L Mehl wrote :
Hello --
The app can allow no more than 32,000 data points (1 column of
numbers) to be imported using a text file.
[1]
Is there a way to load the file into an array, count the records
loaded, and warn the user if 32,000 has been exceeded?
[2]
Then, if not exceeded, the app would then put the array values into a
column in a worksheet.
Can anyone help with ideas or sample code for doing [1] and [2]?
Thanks for any help.
Larry Mehl
mehl_at_cyvest.com