The last Row may have "B" purposely empty, so I would use
' // Find the last row with data in it.
Dim LR As long
LR = Application.WorksheetFunction.Max(Wks.Cells(Rows.Count, "B").End(xlUp).Row, _
Wks.Cells(Rows.Count, "A").End(xlUp).Row
Set RngEnd = Wks.Cells(LR, RngBeg.Column)
If it is possible that both "A" and "B" are empty in the actual last Row
Option Explicit
Function RealLastRow(WsName As String) As Long
Dim LastFormula As Range
Dim LastValue As Range
With Worksheets(WsName)
On Error Resume Next
Set LastFormula = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
Set LastValue = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
On Error GoTo 0
End With
If LastFormula Is Nothing And LastValue Is Nothing Then
RealLastRow = 1
Exit Function
End If
RealLastRow = Application.WorksheetFunction.Max(LastFormula.Row, LastValue.Row)
End Function
Sub Test_RealLastRow()
Dim Ws As Worksheet
For Each Ws In Worksheets
MsgBox RealLastRow(Ws.Name)
Next
End Sub