[font=Verdana][color=darkblue]Function[/color] MyMode(X [color=darkblue]As[/color] [color=darkblue]Variant[/color]) [color=darkblue]As[/color] [color=darkblue]Variant[/color]
[color=darkblue]Dim[/color] Y [color=darkblue]As[/color] [color=darkblue]Variant[/color]
[color=darkblue]Dim[/color] MyArray() [color=darkblue]As[/color] [color=darkblue]Variant[/color]
[color=darkblue]If[/color] [color=darkblue]TypeOf[/color] X [color=darkblue]Is[/color] Range [color=darkblue]Then[/color]
[color=darkblue]Set[/color] X = Intersect(ActiveSheet.UsedRange, X)
[color=darkblue]For[/color] [color=darkblue]Each[/color] Y [color=darkblue]In[/color] X.Cells
[color=darkblue]With[/color] WorksheetFunction
[color=darkblue]If[/color] .IsNumber(Y) [color=darkblue]Or[/color] .IsText(Y) [color=darkblue]Then[/color]
Cnt = Cnt + 1
[color=darkblue]ReDim[/color] [color=darkblue]Preserve[/color] MyArray(1 [color=darkblue]To[/color] Cnt)
MyArray(Cnt) = Y
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]Next[/color] Y
[color=darkblue]ElseIf[/color] IsArray(X) [color=darkblue]Then[/color]
[color=darkblue]For[/color] [color=darkblue]Each[/color] Y [color=darkblue]In[/color] X
[color=darkblue]With[/color] WorksheetFunction
[color=darkblue]If[/color] .IsNumber(Y) [color=darkblue]Or[/color] .IsText(Y) [color=darkblue]Then[/color]
Cnt = Cnt + 1
[color=darkblue]ReDim[/color] [color=darkblue]Preserve[/color] MyArray(1 [color=darkblue]To[/color] Cnt)
MyArray(Cnt) = Y
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]Next[/color] Y
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]With[/color] Application
MyMode = .Index(MyArray, .Mode(.Match(MyArray, MyArray, 0)))
[color=darkblue]End[/color] [color=darkblue]With[/color]
[color=darkblue]End[/color] [color=darkblue]Function[/color]
[/font]