I'm trying to get the last row and column of a used range.
To get the last row and column I use the code below
Dim varCurrentUsedRange As Variant
Dim LastRow As Long
Dim LastCol As Long
varCurrentUsedRange = ActiveSheet.UsedRange
LastRow = UBound(varCurrentUsedRange )
LastCol = UBound(varCurrentUsedRange , 2)
This code returns exactly the last used row number, even the first used cell is not in Row 1.
But it returns the number of used columns not the last used column.
For example, if the first used column is 2 and last one is 6 it's expected to return 6 but it returns only 5 (number of used column).
So how to get the last used column number regardless the starting column?
Thank you in advance.