• 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
Defining an excel function with applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Defining an excel function with applescript
      • From: Stan Cleveland <email@hidden>
  • Prev by Date: Re: "a reference to"
  • Next by Date: Should I not have avoided Leopard?
  • Previous by thread: Re: Obfuscations and little white lies
  • Next by thread: Re: Defining an excel function with applescript
  • Index(es):
    • Date
    • Thread