top of page

Module_01_Select_Cells

Copy and paste the below into a module in VBA

'Enable the developper tab in excel

'--------------------------------------------------------------------------

 Sub select_single_Cell_1()

     'Simple A2 select using Range

 

    Range("A2").Select

     

End Sub

'--------------------------------------------------------------------------

 

Private Sub select_single_Cell_2()

'Simple C1 select using Cells

 

    Cells(1, 3).Select

    'Cells(2, ActiveCell.column).Select

     

End Sub

'--------------------------------------------------------------------------

 

Sub select_range_of_cells_1()

'Muptiple cells select using Range A2:B10

 

    Range("A2:B10").Select

     

End Sub

'--------------------------------------------------------------------------

 

Sub select_range_of_cells_2()

'Muptiple cells select using Range and Cells C2:D10

 

    Range(Cells(2, 3), Cells(10, 4)).Select

 

End Sub

 

Sub select_move_selection_one_down()

'This moves the entire selection one cell down

     

    Selection.Offset(1, 0).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_one_UP()

'This moves the active cell one cell up

 

    ActiveCell.Offset(-1, 0).Select

     

End Sub

'--------------------------------------------------------------------------

 

Sub select_one_DOWN()

'This moves the active cell one cell down

 

    ActiveCell.Offset(1, 0).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_one_RIGHT()

'This moves the active cell one cell right

 

    ActiveCell.Offset(0, 1).Select

     

End Sub

'--------------------------------------------------------------------------

 

Sub select_one_LEFT()

'This moves the active cell one cell left

     

    ActiveCell.Offset(0, -1).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_next_non_empty_cell_UP()

'like pushing Ctrl on keyboard: takes you to next non empty cell

     

    ActiveCell.End(xlUp).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_next_non_empty_cell_DOWN()

'like pushing Ctrl on keyboard: takes you to next non empty cell

     

    ActiveCell.End(xlDown).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_next_non_empty_cell_RIGHT()

'like pushing Ctrl on keyboard: takes you to next non empty cell

     

    ActiveCell.End(xlToRight).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub select_next_non_empty_cell_LEFT()

'like pushing Ctrl on keyboard: takes you to next non empty cell

     

    ActiveCell.End(xlToLeft).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub Select_UsedRange()

'selects all the used range including formatted cells

 

    ActiveSheet.UsedRange.Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub Select_CurrentRegion()

'like pushing Ctrl + * on keyboard: selects area

     

    ActiveCell.CurrentRegion.Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub Select_A1_Right_Down()

'Selects A1, then Ctrl + Right then Ctrl + Down

    Range("A1").Select

    Range(Selection, Selection.End(xlToRight)).Select

    Range(Selection, Selection.End(xlDown)).Select

 

End Sub

'--------------------------------------------------------------------------

 

Sub Cells_Loop()

'Display a messge box for each cell in the selection

 

    For Each cell In Selection

        MsgBox cell.Value

    Next cell

     

End Sub

'--------------------------------------------------------------------------

 

Sub Map_Cells_coordinates_to_sheet()

'Adds a sheet with the coordinates of the cells object

'e.g. how would you quicly know that Cells(9,7) is G9? run this and all will be revealed

 

    Sheets.Add

     

    Cells(1, 1) = "1, 1"

    Cells(1, 2) = "1, 2"

    Cells(1, 3) = "1, 3"

    Cells(1, 4) = "1, 4"

    Cells(1, 5) = "1, 5"

    Cells(1, 6) = "1, 6"

    Cells(1, 7) = "1, 7"

    Cells(1, 8) = "1, 8"

    Cells(1, 9) = "1, 9"

    Cells(1, 10) = "1, 10"

     

    Cells(2, 1) = "2, 1"

    Cells(2, 2) = "2, 2"

    Cells(2, 3) = "2, 3"

    Cells(2, 4) = "2, 4"

    Cells(2, 5) = "2, 5"

    Cells(2, 6) = "2, 6"

    Cells(2, 7) = "2, 7"

    Cells(2, 8) = "2, 8"

    Cells(2, 9) = "2, 9"

    Cells(2, 10) = "2, 10"

     

    Cells(3, 1) = "3, 1"

    Cells(3, 2) = "3, 2"

    Cells(3, 3) = "3, 3"

    Cells(3, 4) = "3, 4"

    Cells(3, 5) = "3, 5"

    Cells(3, 6) = "3, 6"

    Cells(3, 7) = "3, 7"

    Cells(3, 8) = "3, 8"

    Cells(3, 9) = "3, 9"

    Cells(3, 10) = "3, 10"

     

    Cells(4, 1) = "4, 1"

    Cells(4, 2) = "4, 2"

    Cells(4, 3) = "4, 3"

    Cells(4, 4) = "4, 4"

    Cells(4, 5) = "4, 5"

    Cells(4, 6) = "4, 6"

    Cells(4, 7) = "4, 7"

    Cells(4, 8) = "4, 8"

    Cells(4, 9) = "4, 9"

    Cells(4, 10) = "4, 10"

     

    Cells(5, 1) = "5, 1"

     

    Cells(5, 2) = "5, 2"

    Cells(5, 3) = "5, 3"

    Cells(5, 4) = "5, 4"

    Cells(5, 5) = "5, 5"

    Cells(5, 6) = "5, 6"

    Cells(5, 7) = "5, 7"

    Cells(5, 8) = "5, 8"

    Cells(5, 9) = "5, 9"

    Cells(5, 10) = "5, 10"

     

    Cells(6, 1) = "6, 1"

    Cells(6, 2) = "6, 2"

    Cells(6, 3) = "6, 3"

    Cells(6, 4) = "6, 4"

    Cells(6, 5) = "6, 5"

    Cells(6, 6) = "6, 6"

    Cells(6, 7) = "6, 7"

    Cells(6, 8) = "6, 8"

    Cells(6, 9) = "6, 9"

    Cells(6, 10) = "6, 10"

     

    Cells(7, 1) = "7, 1"

    Cells(7, 2) = "7, 2"

    Cells(7, 3) = "7, 3"

    Cells(7, 4) = "7, 4"

    Cells(7, 5) = "7, 5"

    Cells(7, 6) = "7, 6"

    Cells(7, 7) = "7, 7"

    Cells(7, 8) = "7, 8"

    Cells(7, 9) = "7, 9"

    Cells(7, 10) = "7, 10"

     

    Cells(8, 1) = "8, 1"

    Cells(8, 2) = "8, 2"

    Cells(8, 3) = "8, 3"

    Cells(8, 4) = "8, 4"

    Cells(8, 5) = "8, 5"

    Cells(8, 6) = "8, 6"

    Cells(8, 7) = "8, 7"

    Cells(8, 8) = "8, 8"

    Cells(8, 9) = "8, 9"

    Cells(8, 10) = "8, 10"

     

    Cells(9, 1) = "9, 1"

    Cells(9, 2) = "9, 2"

    Cells(9, 3) = "9, 3"

    Cells(9, 4) = "9, 4"

    Cells(9, 5) = "9, 5"

    Cells(9, 6) = "9, 6"

    Cells(9, 7) = "9, 7"

    Cells(9, 8) = "9, 8"

    Cells(9, 9) = "9, 9"

    Cells(9, 10) = "9, 10"

     

    Cells(10, 1) = "10, 1"

    Cells(10, 2) = "10, 2"

    Cells(10, 3) = "10, 3"

    Cells(10, 4) = "10, 4"

    Cells(10, 5) = "10, 5"

    Cells(10, 6) = "10, 6"

    Cells(10, 7) = "10, 7"

    Cells(10, 8) = "10, 8"

    Cells(10, 9) = "10, 9"

    Cells(10, 10) = "10, 10"

 

End Sub

'--------------------------------------------------------------------------

STAY IN TOUCH

Send me an email at:

Join our mailing list

Will not spam, Will not sell !!!

bottom of page