返回列表 上一主題 發帖

[發問] 如何避開按Enter後自動移動的設定

[發問] 如何避開按Enter後自動移動的設定

巨集想在指定TargetRng範圍輸入資料後會自動右移兩格,
但如何避開按Enter 鍵後, 儲存格可能會自動向上下左右方向移動的設定, 因各電腦可能有不同設定
請問巨集應如何修改呢?
  1. Private Sub Worksheet_Change(ByVal Target As Range)
  2. Dim Target_Row As Integer
  3. If Not Application.Intersect(Target, Range("TargetRng")) Is Nothing Then
  4. ActiveCell.Offset(0, 2).Select
  5. End If
  6. End Sub
複製代碼

回復 1# enoch
是這樣嗎?
  1. Option Explicit
  2. Private Sub Worksheet_Change(ByVal Target As Range)
  3.     With Target
  4.         If Not Application.Intersect(.Cells(1), Range("TargetRng")) Is Nothing Then
  5.             .Cells(1).Offset(0, 2).Select
  6.         End If
  7.     End With
  8. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

是的, 謝謝你

TOP

回復 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
Just do it.

TOP

        靜思自在 : 要批評別人時,先想想自己是否完美無缺。
返回列表 上一主題