' note WS is a Worksheet object
' used as late binding
Public Function fnLastRow(ByVal strColumn As String, Optional ByRef WS As Object) As Long
If WS Is Nothing Then Set WS = ActiveSheet
fnLastRow = WS.Cells(WS.Rows.count, ToColNum(strColumn, WS)).End(-4162).row
End Function
Public Function fnLastColumn(ByVal lngrow As Long, Optional ByRef WS As Object) As String
If WS Is Nothing Then Set WS = ActiveSheet
fnLastColumn = ToColLetter(WS.Cells(lngrow, WS.Columns.count).End(-4159).Column)
End Function
' https://www.extendoffice.com/documents/excel/3765-excel-convert-column-label-to-number.html
Public Function ToColNum&(ByVal ColName As String, Optional ByRef WS As Object)
If WS Is Nothing Then Set WS = ActiveSheet
ToColNum = WS.Range(ColName & 1).Column
End Function
' https://www.extendoffice.com/documents/excel/3765-excel-convert-column-label-to-number.html
Public Function ToColLetter$(ByVal ColNumber As Integer, Optional ByRef WS As Object)
If WS Is Nothing Then Set WS = ActiveSheet
ToColLetter = Split(WS.Cells(1, ColNumber).Address, "$")(1)
End Function