LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Change UDF to work as array formula

I have the following UDF. It count the number of any digit in a cell

Function NDIG(ce As String, no As Byte) As Variant
Dim cif(9) As Long
For i = 1 To Len(ce)
Select Case CByte(Mid(ce, i, 1))
Case Is = 0
cif(0) = cif(0) + 1
Case Is = 1
cif(1) = cif(1) + 1
Case Is = 2
cif(2) = cif(2) + 1
Case Is = 3
cif(3) = cif(3) + 1
Case Is = 4
cif(4) = cif(4) + 1
Case Is = 5
cif(5) = cif(5) + 1
Case Is = 6
cif(6) = cif(6) + 1
Case Is = 7
cif(7) = cif(7) + 1
Case Is = 8
cif(8) = cif(8) + 1
Case Is = 9
cif(9) = cif(9) + 1
End Select
Next
NDIG = cif(no)
End Function

I use i by typing the number I want counted in a1 and the numbers fro, 0 to
9 in B1:B10. I then enter the UDF in C1 like =NDIG($A$1;B1) and copy down to
C10, and it retunrs the number of any digit in the cell.

Now I wonder if the UDF can be changes, so I can enter it as an array
formula in C1:C10 in stead of having to copy it?

Jan



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't seem to get my Array formula to work................ Dan the Man[_2_] Excel Discussion (Misc queries) 3 August 21st 08 08:04 PM
VLOOKUP does not work with array formula axb Excel Worksheet Functions 1 February 6th 08 08:09 PM
Array formula in a makro want work Makelei Excel Programming 5 August 27th 07 01:38 PM
array formula does not work Sergio Excel Worksheet Functions 5 October 1st 06 06:48 PM
Will an Array Formula work here? Rob Gould Excel Discussion (Misc queries) 2 February 1st 05 01:25 PM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"