Be the first user to complete this post

  • 0
Add to List

VBA Excel - Cells, Ranges and Offset : Range

Format: Range (“ColumnNameRowNumber”)

Ex: In VBA-Excel when you say Range(“A5”) it’s very easy to understand that you are talking about 5th row in 1st column (“A”)

As the name states Range, you can select a range is cells using this function

Ex: Range (“A1:B5”).Copy means copy all the cells between A1 to B5

To know more about Copy/Paste in VBA-Excel click here (link to VBA-Excel Copy Paste)


Range (“A1, A5, A9, C1:C8”).Select

Means select cells A1,A5,A9 and then all the cells from C1 to C8

  • Open a new Excel WorkBook and press “Alt+F11” to open the Visual Basic Editor
  • Copy Paste the following code
Sub FnRangeExp

Dim mainworkBook as WorkBook

Set mainWorkBook  = ActiveWorkBook


End Sub

Result: In “Sheet1” in all the cells from Range A1 to B5 put ‘0’

Also Read:

  1. VBA-Excel: Array Functions – IsArray()
  2. VBA-Excel: String Functions – Len()
  3. VBA-Excel: User Forms
  4. VBA-Excel: Get all the WeekDays or Working days in Specified Date Range, (excluding Satudays and Sundays)
  5. VBA Excel - Cells, Ranges and Offset: Refer to Cells by Using Shortcut Notation
  6. VBA-Excel: Consolidator – Merge or Combine Multiple Excel Files Into One
  7. VBA-Excel: Date-Time Functions – FormatDateTime()
  8. VBA-Excel: Clear data from Excel Sheet(WorkSheet)