Be the first user to complete this post

  • 0
Add to List

VBA-Excel: UsedRange

In VBA-Excel, UsedRange is very effective property when it comes to deal with the excel file which contains data. Right from formatting options of excel sheet to copy pasting the data, getting informations about rows or columns or clearing the data from excel.

As the name clearly states that it talks about all the cells in an Excel which are filled. ( All the Range which is used)



Dim mainworkBook As Workbook

Set mainworkBook = ActiveWorkbook

Get the number of Used rows


This will give you the number of Rows which are used.

Clear all the data from the Excel Sheet


Copy the entire data from the Excel Sheet


To know more about copy/paste the data using VBA-Excel click here.

Clear all the contents from the Excel Sheet


Clear Border lines from the Excel Sheet


Wrap Text in Excel Sheet

mainworkbook.Sheets("DummySheet").UsedRange.WrapText = True

Also Read:

  1. VBA-Excel: WorkBook.Save Method
  2. VBA-Excel: Create a WorkBook at Runtime.
  3. Excel Macro - Visual Basic Editor
  4. VBA-Excel: Copy/Paste data - Copy the Entire row data and paste it to another row
  5. VBA Excel - Cells, Ranges and Offset: Refer to Cells by Using Shortcut Notation
  6. VBA Excel - Cells, Ranges and Offset: Refer Range by using A1 Notations
  7. VBA-Excel: Add/Insert multiple objects from a folder in an Excel Document.
  8. Excel-VBA : Change Passwords for all the WorkSheets in one shot