標題:
[發問]
如何避開按Enter後自動移動的設定
[打印本頁]
作者:
enoch
時間:
2015-9-15 09:52
標題:
如何避開按Enter後自動移動的設定
巨集想在指定TargetRng範圍輸入資料後會自動右移兩格,
但如何避開按Enter 鍵後, 儲存格可能會自動向上下左右方向移動的設定, 因各電腦可能有不同設定
請問巨集應如何修改呢?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Target_Row As Integer
If Not Application.Intersect(Target, Range("TargetRng")) Is Nothing Then
ActiveCell.Offset(0, 2).Select
End If
End Sub
複製代碼
作者:
GBKEE
時間:
2015-9-15 09:57
回復
1#
enoch
是這樣嗎?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not Application.Intersect(.Cells(1), Range("TargetRng")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
End With
End Sub
複製代碼
作者:
enoch
時間:
2015-9-15 10:16
是的, 謝謝你
作者:
jsc0518
時間:
2018-7-7 08:04
回復
2#
GBKEE
版主早安
請教一下我依照您的語法改了一下,想請教是否可以簡化
B10~F10
.
.
.
B23~F23
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not Application.Intersect(.Cells(1), Range("B10:D10")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B11:D11")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B12:D12")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B13:D13")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B14:D14")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B15:D15")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B16:D16")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B17:D17")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B18:D18")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B19:D19")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B20:D20")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B21:D21")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B22:D22")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
If Not Application.Intersect(.Cells(1), Range("B23:D23")) Is Nothing Then
.Cells(1).Offset(0, 2).Select
End If
End With
End Sub
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)