ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check number of rows? (https://www.excelbanter.com/excel-programming/383669-check-number-rows.html)

David Billigmeier

Check number of rows?
 
I currently have the following code set up which displays a message box if
the csv I'm importing has greater than 256 fields. Is there a way to also
check if the csv has greater than 65,536 rows?

fileLocation = Application.GetOpenFilename("ASCII
(*.csv;*.txt;*.dat),*.csv;*.txt;*.dat,All Files (*.*),*.*")

filein = FreeFile()
Open fileLocation For Input As filein
Line Input #filein, l
If (Len(l) - Len(Replace(l, ",", "")) 255) Then
MsgBox ("Cannot import, input file has more than 256 fields")
Exit Sub
End If


Thanks

--
Regards,
Dave

Tom Ogilvy

Check number of rows?
 
1)loop through it and count the number of rows.

2)read it all at once into one variable and count the number of VbCRLF

do 2, then use split to put it in a variable. check the Ubound

--
Regards,
Tom Ogilvy



"David Billigmeier" wrote:

I currently have the following code set up which displays a message box if
the csv I'm importing has greater than 256 fields. Is there a way to also
check if the csv has greater than 65,536 rows?

fileLocation = Application.GetOpenFilename("ASCII
(*.csv;*.txt;*.dat),*.csv;*.txt;*.dat,All Files (*.*),*.*")

filein = FreeFile()
Open fileLocation For Input As filein
Line Input #filein, l
If (Len(l) - Len(Replace(l, ",", "")) 255) Then
MsgBox ("Cannot import, input file has more than 256 fields")
Exit Sub
End If


Thanks

--
Regards,
Dave



All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com