Re: Excel Find an empty cell
Re: Excel Find an empty cell
- Subject: Re: Excel Find an empty cell
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 27 Sep 2006 00:03:23 -0700
- Thread-topic: Excel Find an empty cell
On 9/26/06 7:16 PM, "Brandon Hunt" <email@hidden> wrote:
> Hey I am sorry I was in a hurry when I wrote the response to my own question
>
> What I found was a function (find) that returns the cell that a given set of
> data is in.
>
> find of range "A:A" what ""
In Excel, 'find' is not a class (object), it's a command. (Unlike in
Microsoft Word, where a 'find object' property is class - 'find', and much
more complicated than in Excel.)
So don't use 'of'. (AppleScript is just being nice here, in ignoring your
mistake. Which isn't always such a good thing, as you don't realize your
mistake, and can't see what to do next.)
In the Excel Dictionary, you'll notice that 'find' is a command, which -
like most (not all) commands - has a result. (That makes it like a
'function' in some other languages.) You can see that from the dictionary
entry for 'find'. Unfortunately, Script Editor 2 no longer uses the subtitle
'result' but that's what the -> arrow means at the bottom of the entry:
→ range : The range which the specified data was found.
To make use of the result in succeeding lines of your script, you simply
have to set a variable to the result:
set foundRange to find range "A:A" what ""
--> range "[Workbook5]Sheet1!$A$7"
This is the most basic AppleScript. It seems that what you need to do is
learn AppleScript, the language, before you try to tackle application
scripting, especially an application as complex as Excel. There are many
good books on AppleScript - about 5 or 6 now. The best one on the syntax
(language) is Matt Neuburg's AppleScript: The Definitive Guide , 2nd
edition.
>
> This function finds the first empty cell in column A
>
> Now what I am wanting to do is create two scripts on that will look at an
> excel sheet find the next empty cell and enter the date and time. I have the
> formulas that will find the amount of time that I have worked. This is my
> second script and the first that I want to writ mostly on my own. The last
> on was mainly written by others. I am a newb and was just wondering how to
> store the cell that the find function gives me.
tell application "Microsoft Excel"
set foundRange to find range "A:A" what ""
set value of foundRange to date string of (current date)
end tell
Now you're _sure_ you really want the date string? That's
--> "Tuesday, September 26, 2006"
You really want all that very verbose long date, which excel sees only as
ext, not as a date? You sure you wouldn't prefer the "short date string"?
set value of foundRange to short date string of (current date)
--> 9/26/06
or whatever you use as the format for short dates on your computer in System
Preferences/International/Format. The advantage of this version is that
Excel also understands the system's short date format. Although it appears
in this format in the cell, excel knows it's a date and aligns it on the
right hand side, where it can be used later for calculations, etc. (and you
can change Excel's formatting in Format/Cells if you wish).
You will continue to be dependent on others for writing your scripts until
you get down to learning the AppleScript language. Read a book and learn
about it.
--
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