Hi DonkeyOte
Thanks for the reply
Yes the code that i have is extracting information from a column header, the full function is below as follow
Private Function RangeFinder(ByVal strStrFindWord As String) As String
' search the header column only for the findword
Dim oRange As Range
Dim oFindInRange As Range
Dim strSplitAddress As String
Dim blnNullRange As Boolean
Set oRange = Range("A1", strMaxRange + "1") ' the search range, the currentrow will always be 1 here since we only check the header
On Error Resume Next
Set oFindInRange = oRange.Find(strStrFindWord, LookIn:=xlValues, MatchCase:=False) ' in case someone modifies the header by case
If oFindInRange Is Nothing Then blnNullRange = True
If Not (blnNullRange) Then
strSplitAddress = Split(oFindInRange.Address, "$")(1)
RangeFinder = strSplitAddress
Else
MsgBox ("Header value has been removed / renamed. i cant find " + strStrFindWord + " in the header")
End If
End Function
Sorry, i had a quick glance at the links you recommended for reading and none of them have any reference to my second question i.e. why (1) is used in the split function above. I may be wrong here so please correct me. Any chance you can explain the following questions please?
- Set oRange = Range("A1", strMaxRange + "1") - what does this mean?
- If oFindInRange Is Nothing Then blnNullRange = True - How does this statement gets compiled i.e. whats the logic behind this?
- RangeFinder = strSplitAddress - how does strSplitAddress gets passed to RangeFinder when actually we are passing ByVal strStrFindWord As String?
Bookmarks