Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
oExcelApp = CreateObject("Excel.Application")
oWorkBook = oExcelApp.Workbooks.Open(pFile)
oWorkBook.ReadOnly.Equals(True)
oWorkSheet = oWorkBook.Worksheets(1)
System.Diagnostics.Debug.WriteLine(oWorkSheet.UsedRange.Rows.Count)
[COLOR=red]Returns 99 - One line too many[/color]
oWorkSheet = oWorkBook.Worksheets(2)
System.Diagnostics.Debug.WriteLine(oWorkSheet.UsedRange.Rows.Count)
[COLOR=red]Returns 65536 - Total cell rows[/color]
oWorkSheet = oWorkBook.Worksheets(3)
System.Diagnostics.Debug.WriteLine(oWorkSheet.UsedRange.Rows.Count)
[COLOR=red]Returns 5516 - exact amount[/color]
oWorkSheet = Nothing
oWorkBook.Close()
oExcelApp = Nothing
System.diag.....(oWorkSheet.UsedRange.Rows.Count & ", " & oWorkSheet.UsedRange.Columns.Count & ", " & oWorkSheet.Name)
Function FindLastRow() As Integer
Dim R As Integer
Dim LastRow As Integer
R = XL.ActiveSheet.UsedRange.Rows.Count
LastRow = XL.ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
FindLastRow = LastRow
End Function
Ummm, back up a bit. When you say this the only thing that comes to mind is that you have the excel workbook open and are deleting the cells. If you are querying the workbook from from another program while your editing the workbook in excel itself or some other strange thing along those lines, then yes it is not going to return the correct data.Sorwen,
I tried deleting rows by either selecting rows and pressing 'Delete' or selecting several rows, right click and select 'Delete'.
Possibly. Each step is something that can be done in a program. The problem is you've left a lot out of what is actually happening so it is impossible to say.PRPhx,
Thanks for the tip. Referencing the items in that link seems to work.
I had to delete the rows, save the excel file, close the application and re-open it.
Not sure if this can be done programatically, but in this case, doing it manually works fine.