User Defined Function for Office 2008

A

Ajithabe

Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I am using user defined function "ColourFunction" on earlier versions of Office on Mac. I use that function to add values connected with different colours. For reference I will copy the script I used.

-------------
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)

Dim rCell As Range

Dim lCol As Long

Dim vResult

lCol = rColor.Interior.ColorIndex

If SUM = True Then

For Each rCell In rRange

If rCell.Interior.ColorIndex = lCol Then

vResult = WorksheetFunction.SUM(rCell, vResult)

End If

Next rCell

Else

For Each rCell In rRange

If rCell.Interior.ColorIndex = lCol Then

vResult = 1 + vResult

End If

Next rCell

End If

ColorFunction = vResult

End Function

--------------------
I used it under Module to run on workbook.

Please give me some guidelines or convert this to Applescript that allows me to work on Excel 2008 on Mac.

Thanks a lot in advance your support
 
B

Bob Greenblatt

--------------------
I used it under Module to run on workbook.

Please give me some guidelines or convert this to Applescript that
allows me to work on Excel 2008 on Mac.

Thanks a lot in advance your support
Sorry, but you are just going to have to learn applescript to convert
it. Also, applescripts can not be called as usre functions so I think
you are out of luck and have to wait til the next version of office arrives.

There are many texts and help sites on the web for applescript.
 
J

John_McGhie_[MVP]

You cannot create an Excel "Function" in AppleScript.

So even if you convert the script, you still won't be able to call it as a
function.

Sorry: AppleScript doesn't work that way, which is why I never bothered to
learn it.

Cheers


Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel
I am using user defined function "ColourFunction" on earlier versions of
Office on Mac. I use that function to add values connected with different
colours. For reference I will copy the script I used.

-------------
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As
Boolean)

Dim rCell As Range

Dim lCol As Long

Dim vResult

lCol = rColor.Interior.ColorIndex

If SUM = True Then

For Each rCell In rRange

If rCell.Interior.ColorIndex = lCol Then

vResult = WorksheetFunction.SUM(rCell, vResult)

End If

Next rCell

Else

For Each rCell In rRange

If rCell.Interior.ColorIndex = lCol Then

vResult = 1 + vResult

End If

Next rCell

End If

ColorFunction = vResult

End Function

--------------------
I used it under Module to run on workbook.

Please give me some guidelines or convert this to Applescript that allows me
to work on Excel 2008 on Mac.

Thanks a lot in advance your support

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410 | mailto:[email protected]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top