Active­Cell, as the name clearly indi­cates that the cell which is presently active in your work­sheet, in other words you can if u start typ­ing the value u entered will go to active cell.

Exam­ple:

Function FnActiveCell()

         Dim mainWorkBook As Workbook

         Set mainWorkBook = ActiveWorkbook   

         mainWorkBook.Sheets("Sheet1").Activate

     ActiveCell.Value = 5

End Function

 

You can select a spe­cific cell in work­sheet which you want to be active. Use Range object along Acti­vate 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 Active­Cell by using the Off­set 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 

 


  

2 Thoughts on “VBA-Excel: Cells Ranges Offset — Active Cell

  1. The func­tions you’ve described above to change the Active cell value do not work.

    • Sumit Jain on November 14, 2014 at 6:07 am said:

      Hello,

      I have just ran it, for me its work­ing fine. Could you please give me the details about the error u r getting?

      Sumit

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation