• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: find last row in excel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find last row in excel


  • Subject: Re: find last row in excel
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 31 Jul 2005 10:34:21 -0700
  • Thread-topic: find last row in excel

On 7/31/05 10:10 AM, "Robert Poland" <email@hidden> wrote:

> I wish to find the last row of data in an excel
> spreadsheet. This works, but take too much time.
> Isn't there a command that will do the same thing?
>
> set readRow to 1000
> tell application "Microsoft Excel"
> Activate
> Select Worksheet "Averages"
> set readCell to "$C$" & readRow
> set x to Value of Cell readCell
> repeat while x ‚ 0
> set y to x
> set readCell to "$C$" & readRow
> set x to Value of Cell readCell
> set readRow to readRow + 1
> end repeat
> end tell
> set y to y as integer
> y

You haven't said which version of Excel you have. From the look of it, you
must have Excel X or earlier, not 2004?

Get the UsedRange of the worksheet, set a variable (like c) to the Type
xlLastCell for the SpecialCells of the used range, and a variable (like x)
to the Row of the result - which is the index of the last row in fact, then
get the Value of Row x of the Used Range, which gets you the whole last row
as a list.

Never use Selection.



tell application "Microsoft Excel"
    set ur to UsedRange of ActiveSheet -- or Worksheet "Averages"
    set c to SpecialCells ur Type xlLastCell
    set x to Row of c
    set y to Value of Row x of ur
end tell

--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >find last row in excel (From: Robert Poland <email@hidden>)

  • Prev by Date: find last row in excel
  • Next by Date: Re: find last row in excel
  • Previous by thread: find last row in excel
  • Next by thread: Re: find last row in excel
  • Index(es):
    • Date
    • Thread