Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Cells Ranges Offset - Active Cell

ActiveCell, as the name clearly indicates that the cell which is presently active in your worksheet, in other words you can if u start typing the value u entered will go to active cell.

Example:

Function FnActiveCell()

         Dim mainWorkBook As Workbook

         Set mainWorkBook = ActiveWorkbook   

         mainWorkBook.Sheets("Sheet1").Activate

     ActiveCell.Value = 5

End Function

You can select a specific cell in worksheet which you want to be active. Use Range object along Activate method

Function FnActiveCell()

        Dim mainWorkBook As Workbook

        Set mainWorkBook = ActiveWorkbook

 mainWorkBook.Sheets("Sheet1").Range("A2").Activate

 ActiveCell.Value = 53

End Function

You can also change the ActiveCell by using the Offset property.

Function FnActiveCell()

        Dim mainWorkBook As Workbook

        Set mainWorkBook = ActiveWorkbook   

        mainWorkBook.Sheets("Sheet1").Range("A2").Activate

        ActiveCell.Offset(1, 0).Activate

          ActiveCell.Value = "New Cell"

 End Function 



Also Read:

  1. VBA-Excel: Arrays – Two Dimension, Dynamic Array
  2. VBA-Excel: Add Worksheets For All The Given Dates Except Weekends and Copy The Common Template In Each Worksheet
  3. VBA Codes - Record Macro
  4. VBA-Excel: Date-Time Functions – DateDiff()
  5. VBA Excel – Refer to Multiple Ranges : Union Method
  6. VBA Excel - Cells, Ranges and Offset: Refer Range by using A1 Notations
  7. VBA-Excel: Date-Time Functions – CDate()
  8. VBA Excel - Cells, Ranges and Offset : Offset