I am trying to read information from an excel file but I only want to read rows that have information in them. I am currently using the following loop
VB Code:
For intRow = intStartRow To xlSheet.Cells.Rows.Count ' Read each column of each row into the recordset rst.AddNew rst("LastName") = xlSheet.Cells(intRow, intCol + 1).Value rst("FirstName") = xlSheet.Cells(intRow, intCol + 2).Value rst("FullName") = xlSheet.Cells(intRow, intCol + 3).Value rst("BusinessPhone") = FormatPhone(xlSheet.Cells(intRow, intCol + 4).Value) rst("MobilePhone") = FormatPhone(xlSheet.Cells(intRow, intCol + 5).Value) rst("Pager") = FormatPhone(xlSheet.Cells(intRow, intCol + 6).Value) rst("Email") = xlSheet.Cells(intRow, intCol + 7).Value rst.Update ' Update temporary table intCol = 1 ' Move back to the first column Next intRow
However xlSheet.Cells.Rows.Count returns all the rows in the excel sheet when there are only 95 rows that have actual data in them. How do I just read the rows that have data in them?


Reply With Quote
