gpt4 book ai didi

excel - 在另一个单元格中输入数据并按 Enter 选项后转到特定单元格

转载 作者:行者123 更新时间:2023-12-02 07:32:29 24 4
gpt4 key购买 nike

我有一个 Excel 工作表,我正在 A2、B2 和 C2 中输入数据;按 Enter 键后,我希望光标选择下一行,以便我可以输入 A3、B3 和 C3 等信息

我找到了这个信息

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Range("C2").Value <> "" Then
Range("A3").Select
End If
End Sub

但是它只能运行一次,我如何才能一遍又一遍地重复这个过程

感谢您的帮助......

最佳答案

另一种方式。

  1. 如果您在 A 列中的任意位置键入内容,所选内容将移至 B 列。
  2. 如果您在 B 列中的任意位置键入内容,所选内容将移至 C 列。
  3. 如果您在 C 列的任意位置键入内容,所选内容将移回到 A 列(下一行)。

代码:这位于相关工作表代码区域中。

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Whoa

Application.EnableEvents = False

If Not Target.Cells.CountLarge > 1 Then
If Not Intersect(Target, Columns(1)) Is Nothing Then
Target.Offset(, 1).Select
ElseIf Not Intersect(Target, Columns(2)) Is Nothing Then
Target.Offset(, 1).Select
ElseIf Not Intersect(Target, Columns(3)) Is Nothing Then
Target.Offset(1, -2).Select
End If
End If
Letscontinue:
Application.EnableEvents = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume Letscontinue
End Sub

屏幕截图

enter image description here

关于excel - 在另一个单元格中输入数据并按 Enter 选项后转到特定单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15952263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com