Returns the number of rows VBA selected range of cells, the number of columns, and the active cell of the row and column number

Worksheet_SelectionChange Sub Private (ByVal the Target of As the Range)
    Dim rows_count of As Integer
    Dim rows_id of As Integer
    Dim COLUMN_COUNT of As Integer
    Dim the column_id of As Integer
    COLUMN_COUNT = Selection.Columns.Count 'returns the number of columns selected region
    rows_id = ActiveCell.Row' return to the active cell line No.
    rows_count = Selection.Rows.Count 'selection area to return the number of rows

    column_id = ActiveCell.Column 'return to the active cell's column number
    MsgBox rows_count
    MsgBox COLUMN_COUNT
    MsgBox the column_id
    MsgBox rows_id
End Sub

 



Guess you like

Origin www.cnblogs.com/xwenwu/p/12090343.html