VBA-Excel: Cells Ranges Offset — Active Cell

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 

Also Read about

Cells

Off­set

Range

Range By using A1 Notations

Refer to Cells by Using Short­cut Notation

Refer to Mul­ti­ple Ranges : Union Method

Loop­ing Through a Range of Cells

Select and Acti­vate Cells — Select

Select and Acti­vate Cells — Activate

3D-Ranges — Work­ing with Mul­ti­ple Work­Sheets At The Simultaneously.

Cre­ate Dynamic or Run-time Work­Sheets using Macro

3D-Ranges – Fil­lAcrossSheets Method

Cells Ranges Off­set — Active Cell

Cur­ren­tRe­gion

Happy Macro­ing :)

Sumit Jain

 





    

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

    1. Sumit Jain Post author

      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>

%d bloggers like this: