I pulled the following code from internet to return my actual used range.
The code works fine and returns the used range until my data surpasses row 256. On row 257 the function quits returning data causing the "oRangeSort" to not be defined. I have received the error in two separate workbooks. Any ideas? Thank you.
Dim oRangeSort As Range
Set oRangeSort = oWorksheet.Range(Cells(1, 1), Cells(FindLastRow, FindLastColumn))
Public Function FindLastRow()
r = ActiveSheet.UsedRange.Rows.Count
C = ActiveSheet.UsedRange.Columns.Count
FindLastRow = r
End Function
Public Function FindLastColumn()
r = ActiveSheet.UsedRange.Rows.Count
C = ActiveSheet.UsedRange.Columns.Count
FindLastColumn = r
End Function
Public Function RealUsedRange() As Range
RealUsedRange = ActiveSheet.Range(Cells(1, 1), Cells(FindLastRow, FindLastColumn)).Address
End Function
Bookmarks