excel 鼠标上下左右移动
.Offset用法:(如果是多选单元格,偏移后选定的依然是区域)
Selection.Offset(-1).select
'up
Selection.Offset(1).select
'down
Selection.Offset(,-1).select
'Left
Selection.Offset(,1).select
'RIght
2.Item用法:(如果选定单元格越界,也会产生错误)
Selection.Item(0,1).select
'up
Selection.Item(2,1).select
'down
Selection.Item(1,0).select
'Left
Selection.Item(1,2).select
'RIght
3.Item省略用法:(如果选定单元格越界,也会产生错误)
Selection(0,1).select
'up
Selection(2,1).select
'down
Selection(1,0).select
'Left
Selection(1,2).select
'RIght
Private
Sub
CommandButton1_Click()
Range(
"F6"
).
Select
End
Sub
Private
Sub
CommandButton2_Click()
Selection.Offset(-1).
Select
'Up
End
Sub
Private
Sub
CommandButton3_Click()
Selection.Offset(1).
Select
'Down
End
Sub
Private
Sub
CommandButton4_Click()
Selection.Offset(, -1).
Select
'Left
End
Sub
Private
Sub
CommandButton5_Click()
Selection.Offset(, 1).
Select
'Right
End
Sub
Private
Sub
CommandButton6_Click()
Selection.Item(0, 1).
Select
'Up
End
Sub
Private
Sub
CommandButton7_Click()
Selection(2, 1).
Select
'Down
End
Sub
Private
Sub
CommandButton8_Click()
Selection(1, 0).
Select
'Left
End
Sub
Private
Sub
CommandButton9_Click()
Selection.Item(1, 2).
Select
'Right
End
Sub