daveofgv
Well-known member
hello all -
Quick question and I hope someone can help.....
I have a windows from that reads from an excel file. Everyting works great except I want to limit the amount of rows that my program can read from.
Example:
The program can read each row of the excel file until it reaches no more lines -
Then on the bottom I have
I would like for it to only read the first 5 rows instead of going all the way to the end.
Would anyone be able to help?
Thanks in advanced
daveofgv
Quick question and I hope someone can help.....
I have a windows from that reads from an excel file. Everyting works great except I want to limit the amount of rows that my program can read from.
Example:
The program can read each row of the excel file until it reaches no more lines -
VB.NET:
Dim xls As New Excel.Application
Dim sheet As Excel.Worksheet
xls.Workbooks.Open(txtExcel.Text)
sheet = xls.ActiveWorkbook.Sheets(1)
Dim row As Integer = 1
Do Until sheet.Cells(row, 1) Is Nothing OrElse Len(Trim(sheet.Cells(row, 1).value)) = 0
Then on the bottom I have
VB.NET:
row += 1
Loop
I would like for it to only read the first 5 rows instead of going all the way to the end.
Would anyone be able to help?
Thanks in advanced
daveofgv