Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Cells Ranges Offset — Active Cell

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 

 


 

You may also like...

2 Responses

  1. mIR says:

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

    • Sumit Jain says:

      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 *

%d bloggers like this: