Get a Month value from Excel

Hello,

Is there a way to obtain the value of the month from a cell in Microsoft Excel? In VBA the function was MONTH (). I know that Applescript has a month function as well, but it doesn’t seem to return the proper value for me.
Here is a simple script that returns “missing value” when I use the date 1/1/2008 in the cell.

tell application "Microsoft Excel"
	activate
	set ThisMonth to month of cell 4 of row 42 as text
	set formula of cell 5 of row 42 to ThisMonth
end tell

Thanks in advance,

Tom Carlson

Hi,

the value of the cell represents a date, so use this syntax


set ThisMonth to month of (get value of cell 4 of row 42) as text

You can omit the coercion to text if you want to process the month constant

Thanks again, Stefan. That works. Is there anything you don’t know?

Tom

…and one more question relevant to this.

Is the best way to test to make sure that the cell is not empty like this:

if (get value of range "D42") is not "" then

It works for me, but I want to make sure I am using best practices.

Tom

It’s perfect, the value of an empty cell is an empty string