UsedRange Property
Returns a Range object that represents the used range on the specified worksheet.
expression.UsedRange
*expression * Required. An expression that returns a Worksheet object.
Example
This example adjusts the row height and column width for the used range on the active worksheet to fit the data contained in the range.
Sub AutoFitSpreadsheet()
Dim rngUsedRange
' Set a variable tot he used range in the active sheet.
Set rngUsedRange = Spreadsheet1.ActiveSheet.UsedRange
' Autofit the rows.
rngUsedRange.AutoFitRows
' Autofit the columns.
rngUsedRange.AutoFitColumns
End Sub
Applies to | Worksheet Object
See Also | CurrentRegion Property