L
Lionel H
I have been successfully using the function below since Jim Tomlinson posted
it in 2006. Recently under certain circumstances it has returned an "invalid"
value.
In a case in point:
sh has 19 columns and 70 rows
Cells 1 to 19 of Row 1 have been merged
25 rows have been filtered out using autofilter (filtered col = 19)
If I leave the filtering in place the function is returning 1
If I remove the filtering, it correctly returns 19.
Can anyone explain why and whether there are other circumstances in which it
might behave unexpectedly?
Function fnLastCol(sh As Worksheet) As Long
fnLastCol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
End Function
TIA
it in 2006. Recently under certain circumstances it has returned an "invalid"
value.
In a case in point:
sh has 19 columns and 70 rows
Cells 1 to 19 of Row 1 have been merged
25 rows have been filtered out using autofilter (filtered col = 19)
If I leave the filtering in place the function is returning 1
If I remove the filtering, it correctly returns 19.
Can anyone explain why and whether there are other circumstances in which it
might behave unexpectedly?
Function fnLastCol(sh As Worksheet) As Long
fnLastCol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
End Function
TIA