Vba,行和列编号

Vba,行和列编号,vba,row,Vba,Row,我目前正在编写vba脚本。 单击单元格时是否有接收行和列编号的方法 我希望vba执行的一个示例: a = select.cell.row b = select.cell.column 是否存在类似的内容?右键单击工作表,然后单击“查看代码” 将此代码粘贴到那里 Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim a as Long: a = Target.Row Dim b as Integer: b

我目前正在编写vba脚本。 单击单元格时是否有接收行和列编号的方法

我希望vba执行的一个示例:

a = select.cell.row
b = select.cell.column

是否存在类似的内容?

右键单击工作表,然后单击“查看代码” 将此代码粘贴到那里

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim a as Long: a = Target.Row
    Dim b as Integer: b = Target.Column
End Sub

右键单击工作表,然后单击“查看代码” 将此代码粘贴到那里

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim a as Long: a = Target.Row
    Dim b as Integer: b = Target.Column
End Sub

伊万·莫阿拉(Ivan Moala)的一颗小宝石以图形方式提供了这一点:

Private子工作表\u selection更改(ByVal目标作为范围)
Dim iColor作为整数
“//来自伊万·莫阿拉
'// http://www.mrexcel.com/hof001.php
“//在此网站上找到了已修改的例程
“//注意:如果有条件,则不要使用
“//要保留的格式设置!
“//如果发生错误,请继续
“//用户选择一系列单元格
出错时继续下一步
iColor=Target.Interior.ColorIndex
'对于行偏移量错误,在错误时保持打开状态
如果i颜色<0,则
iColor=48
其他的
iColor=iColor+1
如果结束
“//如果字体颜色相同,则需要此测试
如果iColor=Target.Font.ColorIndex,则iColor=iColor+1
Cells.FormatConditions.Delete
'//水平色带
带有范围(“A”&Target.Row,Target.Address)行(Target.Row)
.FormatConditions.Add类型:=2,公式1:=“TRUE”
.FormatConditions(1).Interior.ColorIndex=iColor
以
'//垂直色带
带范围(Target.Offset(1-Target.Row,0).Address&“:”&Target.Offset(-1,0.Address)”行(Target.Row)
.FormatConditions.Add类型:=2,公式1:=“TRUE”
.FormatConditions(1).Interior.ColorIndex=iColor
以
端接头

伊万·莫阿拉(Ivan Moala)的一颗小宝石以图形方式提供了这一点:

Private子工作表\u selection更改(ByVal目标作为范围)
Dim iColor作为整数
“//来自伊万·莫阿拉
'// http://www.mrexcel.com/hof001.php
“//在此网站上找到了已修改的例程
“//注意:如果有条件,则不要使用
“//要保留的格式设置!
“//如果发生错误,请继续
“//用户选择一系列单元格
出错时继续下一步
iColor=Target.Interior.ColorIndex
'对于行偏移量错误,在错误时保持打开状态
如果i颜色<0,则
iColor=48
其他的
iColor=iColor+1
如果结束
“//如果字体颜色相同,则需要此测试
如果iColor=Target.Font.ColorIndex,则iColor=iColor+1
Cells.FormatConditions.Delete
'//水平色带
带有范围(“A”&Target.Row,Target.Address)行(Target.Row)
.FormatConditions.Add类型:=2,公式1:=“TRUE”
.FormatConditions(1).Interior.ColorIndex=iColor
以
'//垂直色带
带范围(Target.Offset(1-Target.Row,0).Address&“:”&Target.Offset(-1,0.Address)”行(Target.Row)
.FormatConditions.Add类型:=2,公式1:=“TRUE”
.FormatConditions(1).Interior.ColorIndex=iColor
以
端接头

被告知
选择可以包含多个列或行,在这种情况下,您的代码将存储最左上角的单元格行和列索引。被告知
选择可以包含多个列或行,在这种情况下,您的代码将存储最左上角的单元格行和列索引