码迷,mamicode.com
首页 > 编程语言 > 详细

VBA返回选中单元格区域的行数、列数,以及活动单元格的行号和列号

时间:2019-12-24 11:33:19      阅读:1089      评论:0      收藏:0      [点我收藏+]

标签:cell   ksh   sub   单元格   active   onchange   vat   区域   targe   

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim rows_count As Integer
    Dim rows_id As Integer
    Dim column_count As Integer
    Dim column_id As Integer
    column_count = Selection.Columns.Count ‘返回选择区域列数
    rows_id = ActiveCell.Row  ‘返回活动单元格的行号
    rows_count = Selection.Rows.Count  ‘返回选择区域的行数

    column_id = ActiveCell.Column  ‘返回活动单元格的列号
    MsgBox rows_count
    MsgBox column_count
    MsgBox column_id
    MsgBox rows_id
End Sub

 



VBA返回选中单元格区域的行数、列数,以及活动单元格的行号和列号

标签:cell   ksh   sub   单元格   active   onchange   vat   区域   targe   

原文地址:https://www.cnblogs.com/xwenwu/p/12090343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!