Excel2010中实现输入两个字符自动切换单元格的操作方法
相关话题
在数据输入时,经常要输入固定的字符数后,要按回车键,怎么实现输入后自动换单元格,提高输入速度。今天,小编就教大家在Excel2010中实现输入两个字符自动切换单元格的操作方法。
Excel2010中实现输入两个字符自动切换单元格的操作步骤如下:
你电脑上必须有一个能有运行Microsoft visual basic代码编辑器,因为这需要用VB代码来实现。打开EXCEL软件,选择你要输入数据的工作表。

右击工作表,选择查看代码。

在编辑区里拷入以下代码:
Private Sub TextBox1_Change()
If Len(Me.TextBox1.Text) <> 2 Then Exit Sub
Me.TextBox1.Activate
ActiveCell = Me.TextBox1.Text
Me.TextBox1.Text = ""
Me.TextBox1.Activate
ActiveCell.Activate
Application.SendKeys "~"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With TextBox1
.Left = ActiveCell.Left
.Top = ActiveCell.Top
.Width = ActiveCell.Width
.Height = ActiveCell.Height
End With
Me.TextBox1.Activate
End Sub

现在就可实现输入2个字符自动切换单元格。
要是想输入其它个固定字符,只要将“If Len(Me.TextBox1.Text) <> 2 Then Exit Sub”代码里的2换成相应的数字,比如3、4。

要是您宏安全性设置过高,会导致代码无法运行,所以你必需进行宏的安全性设置,在工具——宏——安全性。

将安全性设置为低或中、不要设置为高和非常高。

Excel2010中实现输入两个字符自动切换单元格的操作方法的评论条评论