View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kkknie[_142_] kkknie[_142_] is offline
external usenet poster
 
Posts: 1
Default Marking my sub into a function i can use in excel

Make sure you put this in a standard Module (not a sheet o
ThisWorksheet).

Code
-------------------
Public Function countnonwhite(rInput As Range) as Single

Dim nonwhite As Single
nonwhite = 0
countnonwhite = 0

For Each c In ActiveSheet.Range(rInput)
If c.Interior.ColorIndex < -4142 Then nonwhite = nonwhite + 1
Next

countnonwhite = nonwhite

End Su
-------------------

Use it by entering =countnonwhite(A1:C100)



--
Message posted from http://www.ExcelForum.com