360U2005471648級分類:編程開發(fā)被瀏覽53次2019.11.08
匿名網(wǎng)友2019.11.09
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r1%, r%, c1%, c%
r1 = Target.Row
c1 = Target.Column
If Application.MoveAfterReturnDirection = xlDown Then
r = r1 - 1: c = c1
If r1 = Cells.Rows.Count Then r = r1
End If
If Application.MoveAfterReturnDirection = xlUp Then
r = r1 + 1: c = c1
If r1 = 1 Then r = 1
End If
If Application.MoveAfterReturnDirection = xlToLeft Then
r = r1: c = c1 + 1
If c1 = 1 Then c = 1
End If
If Application.MoveAfterReturnDirection = xlToRight Then
r = r1: c = c1 - 1
If c1 = Cells.Columns.Count Then c = c1
End If
If r > 0 And c > 0 Then
If Cells(r, c) <> "" Then
Cells(r, c) = 0
Cells(r, c).NumberFormatLocal = "G/通用格式"
End If
End If
End Sub
說明:此代碼不僅僅回車后自動歸零。