1)Slection from cell to cell - Left to Right

     

  • Through this program we can select requried range of cells

 

     

     

    Copy the Code:

     

    Private Sub CommandButton1_Click()
    'selecting of cells from range c3 to till the end of 3rd row across the columns
    Range(Range("C3"), Range("C3").End(xlToRight)).Columns.Select
    End Sub

     

     

    'Range("C3").End(xlToRight)).Columns.Select
  • It denotes from the C3 cell to till the end all the cells will select
  •  

    Properties and Methods Used:

     

    • Select Method
    • end(xltoright) Method
    • Columns Property
    • Range Method

     

     

    2)Slection from cell to cell - Top to Bottom

     

     

    Private Sub CommandButton1_Click()
    'Select down cells starting from B4
    Range(Range("B4"), Range("B4").End(xlDown)).Select
    End Sub

     

     

     

     

    3)Select all Cells

     

     

    Copy the Code:

     

    Private Sub CommandButton1_Click()
    Dim d As Long, w As Integer
    d = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
    w = Range(Range("A1"), Range("A1").End(xlToRight)).Columns.Count
    Range(Cells(1, 1), Cells(d, w)).Select
    End Sub

     

     

  • For rows assign data type as LONG
  •  

  • Variable "d" returns rows count starting from "A1" to till the end., i.e last data cell
  •  

  • Variable "w" returns columns count starting from "A1" to till the end., i.e last data cell
  •  

     

    4)Select 3rd row in SELECTED RANGE

     

     

     

     

    5)Select from specific cell to till the end(down):