帮我写一个EXCEL的代码,简单的

要求是,选择sheet1的单元格J6后,按回车键,自动选中单元格H8
2025-02-24 15:01:28
推荐回答(2个)
回答1:

代码如下:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 6 And Target.Column = 10 Then
        Cells(8, 8).Select
    End If
End Sub

代码不能放在模块中,需要放在工作表中。

回答2:

Private Sub WorkSheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$J$6" Then
Cells(8, "h").Select
End If
End Sub