Reading the last row from an external Excel spreadsheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top