I opened an Excel-Sheet I wanted to load and manually counted Rows and Columns, because my App always crashed. I then used:
rows = 3114; //manually counted
columns = 29 //manually counted
calcRows = ws.UsedRange.Rows.Count;
calcColumns = ws.UsedRange.Columns.Count;
After running the code, it showed:
rows = 3114
columns = 29
calcRows = 3117
calcColumns = 30
I couldn't find any data in the 3 more rows which were calculated or the additional column. Only after deleting those rows the method calculated the right way. So maybe there were cells already used but the content was deleted - and the mentioned method counts those
Since the Sheet is manually managed by the enduser and new data are manually added, I cannot be sure the counting is right this way. Is there a better way?
I read about:
usedCol = ThisWorkbook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
usedRow = ThisWorkbook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
But my App does not understand "xlCellTypeLastCell".