AndrewMozley
Programmer
I need to know how many rows there are in Sheet 1 of an XL workbook that I have opened. The best function that I have found is :
oExcel.Cells.SpecialCells(11).row
However, if the user has a second sheet in the workbook (in which I am not interested), and he had saved the workbook so that that is the current page, then the above function returns the number of rows on the second page, and I then mistakenly only work on a subset of the rows on sheet 1.
I also notice that if Sheet 2 had been saved as the user’s current sheet, then after my program has finished and populated the cells of sheet 1, when the user opens it using Excel, he still starts on Sheet 2, but can then click on sheet 1 to see all the stuff I have generated.
So my question is “How can I make Sheet 1 the current sheet, so that the SpecialCells(11) function works off that sheet, and so that when the user opens the workbook, that is the sheet he sees”
oExcel.Cells.SpecialCells(11).row
However, if the user has a second sheet in the workbook (in which I am not interested), and he had saved the workbook so that that is the current page, then the above function returns the number of rows on the second page, and I then mistakenly only work on a subset of the rows on sheet 1.
I also notice that if Sheet 2 had been saved as the user’s current sheet, then after my program has finished and populated the cells of sheet 1, when the user opens it using Excel, he still starts on Sheet 2, but can then click on sheet 1 to see all the stuff I have generated.
So my question is “How can I make Sheet 1 the current sheet, so that the SpecialCells(11) function works off that sheet, and so that when the user opens the workbook, that is the sheet he sees”