这个代码已经实现了选中单元格的行号,只是它把行号存在了变量row1里面,如果想显示,可以在后面加一句:
Sub aa()
Dim rng As Range
Dim row1 As Integer
Set rng = Application.InputBox("请选择单元格:", Type:=8)
rng.Activate
'row1 = ActiveCell.Row
MsgBox rng.Row
End Sub
试试这个呢:
Sub bb()
Dim rng As Range
Dim row1 As Integer
On Error Resume Next
Set rng = Application.InputBox("请选择单元格:", Type:=8)
If rng Is Null Then Exit Sub
row1 = rng.Row()
MsgBox row1
End Sub
有疑问,请Hi我或给我发百度消息
GoodLuck!
试试这个吧
Sub cc()
Dim row1 As Long 'row1是所选择单元格的行号
Dim mycell As Range
Set mycell = Application.InputBox(prompt:="Select a cell", Type:=8)
row1 = mycell.Row
MsgBox row1
End Sub
____________________________________________
Row 属性
返回区域中第一个子区域的第一行的行号。Long 类型,只读。
Sub aa()
Dim row1 As Integer 'row1是所选择单元格的行号
Dim a As Range
Set a = Application.InputBox(prompt:="请选择单元格", Type:=8)
a.Select
row1 = ActiveCell.Row
MsgBox row1
End Sub