Defining an excel function with applescript
Defining an excel function with applescript
- Subject: Defining an excel function with applescript
- From: David Erb <email@hidden>
- Date: Thu, 17 Jan 2008 08:13:55 -0500
I have an excel file that uses visual basic to define a function in excel. It allows someone to count a range of numbers based on the background color of the cell.
The visual basic looks like this:
Function CountByColor(InRange As Range, _ WhatColorIndex As Integer, _ Optional OfText As Boolean = False) As Long ' ' This function return the number of cells in InRange with ' a background color, or if OfText is True a font color, ' equal to WhatColorIndex. ' Dim Rng As Range Application.Volatile True
For Each Rng In InRange.Cells If OfText = True Then CountByColor = CountByColor - _ (Rng.Font.ColorIndex = WhatColorIndex) Else CountByColor = CountByColor - _ (Rng.Interior.ColorIndex = WhatColorIndex) End If Next Rng
End Function
You can then call this function from a worksheet cell with a formula like "=COUNTBYCOLOR (A1:A10, 3, FALSE)"
With Excel 2008 for Mac eliminating visual basic, I'm wondering if the above macro can be used with applescript somehow. Or is there another way to count a series of numbers based on the background shading, using only what is available with applescript?
Thanks in advance, -Dave |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden