tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
I have these functions for finding the last row and columns:
How can I adapt them to find the last col for a specific row?
Thanks
Code:
Public Function LRow(ByRef wks As Worksheet) As Long
On Error GoTo Correction
With wks
LRow = wks.Cells.Find(What:="*", _
After:=.Cells(.Rows.Count, .Columns.Count), _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
End With
Exitpoint:
On Error GoTo 0
Exit Function
Correction:
LRow = 1
Resume Exitpoint
End Function
Public Function LRowInCol(ByRef wks As Variant, _
ByRef Col As Variant) As Long
On Error GoTo Correction
If TypeName(wks) = "String" Then Set wks = Worksheets(wks)
LRowInCol = wks.Columns(Col).Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, _
SearchFormat:=False).Row
Exitpoint:
On Error GoTo 0
Exit Function
Correction:
LRowInCol = 1
Resume Exitpoint
End Function
Public Function LCol(ByRef wks As Worksheet) As Long
On Error GoTo Correction
With wks
LCol = .Cells.Find(What:="*", _
After:=.Cells(.Rows.Count, .Columns.Count), _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
End With
Exitpoint:
On Error GoTo 0
Exit Function
Correction:
LCol = 1
Resume Exitpoint
End Function
How can I adapt them to find the last col for a specific row?
Thanks