Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Muaz Bashara   on Mar 07 In MS Office Category.

  
Question Answered By: Trae Thompson   on Mar 07

Option Explicit
Function classify(data1 As Range, whatnum As Integer)
Dim data, loop1 As Long, loop2 As Long, odata As Integer
Dim n As Integer, an As Integer, ans(), vkey
data = data1.Value
For loop1 = 1 To UBound(data, 1)
odata = data(loop1, 1)
For loop2 = 1 To UBound(data, 2)
If odata = data(loop1, loop2) Then
n = n + 1
'Debug.Print odata
Else
'Debug.Print n
'Debug.Print "'" & odata & ":" & loop1 & ":" & loop2
& ":" & n
ReDim Preserve ans(an): ans(an) = n: an = an + 1
odata = data(loop1, loop2)
n = 0
End If
Next
Next
'For loop1 = LBound(ans) To UBound(ans)
' Debug.Print ans(loop1)
'Next
With CreateObject("scripting.dictionary")
For loop1 = LBound(ans) To UBound(ans)
If Not .exists(ans(loop1)) Then
.Add ans(loop1), Nothing
If whatnum = ans(loop1) Then Debug.Print ans(loop1):
classify = _
WorksheetFunction.CountIf(WorksheetFunction.Transpose
(ans), ans(loop1)): _
Exit Function
Else
End If
Next
End With
End Function

i roughly make udf,but no result and error,if have any idea will help.

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Routine needed for continuing numbers. Or get search suggestion and latest updates.


Tagged: