Reading the last row from an external Excel spreadsheet

Reading the last row from an external Excel spreadsheet

Post by Steve Rind » Fri, 03 Mar 2006 02:28:09



xlDown is an Excel constant; PowerPoint doesn't know what it is so you get an
error when you use it.

Substitute the actual value of the constant (-4121) or add this to the
declarations section of your VBA module:

Const xlDown as Long = -4121

By the way, it's a good idea to include the *exact* text of any error messages
when you ask questions like this. It wasn't necessary this time (at least I
don't think so) but in other cases it can be helpful.


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
 
 

Reading the last row from an external Excel spreadsheet

Post by Um9iZXJ0b » Fri, 03 Mar 2006 02:51:30

I need to know the last row in a Excel document which I open from Power Point.

I'm doing something like this:

dim mybook as object
dim n as integer

Set mybook("excel.xls")
mybook.application.visible = true
myboook.sheets("sheet1").select

That part is working perfectly, open the book, read some cells, is fine, but
I can't use this instruction (which work perfectly in Excel):
n = mybook.application.ActiveCell.End(xlDown).Row

Someone knows why? Is there another way to find out the last cell using a
similar instruction or simply it is impossible to use Excel VBA from
PowerPoint VBA? Another idea to get the last row besides reading line by line?