wsnyder
Board Regular
- Joined
- Sep 23, 2018
- Messages
- 224
- Office Version
- 365
- Platform
- Windows
Hi all,
Using Excel 365.
My Function is returning an error:
The range exists and is correct
The SearchTerm exists.
What am I missing?
Here's the Function that is calling the FindColumnHeader Function
Thanks,
-w
Using Excel 365.
My Function is returning an error:
VBA Code:
Public Function FindColumnHeader(rng As Range, _
SearchTerm As String) As Long
FindColumnHeader = rng.Find(what:=SearchTerm, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False).Column
End Function
The range exists and is correct
The SearchTerm exists.
What am I missing?
Here's the Function that is calling the FindColumnHeader Function
Code:
Private Function GetColumnArray(v As Variant, _
rng As Range) As Variant
Dim i As Long
Dim x As Long
Dim crit As String
Dim tempColumnArray() As Long
x = 1
For i = LBound(v) To UBound(v)
ReDim Preserve tempColumnArray(x)
crit = CStr(v(i))
tempColumnArray(x) = FindColumnHeader(rng:=rng, _
SearchTerm:=crit)
x = x + 1
Next i
GetColumnArray = CVar(tempColumnArray)
End Function
Thanks,
-w