在Excel VBA中自动获取价值 [英] Auto get value in excel VBA
本文介绍了在Excel VBA中自动获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在单元格中键入AOM字母,我想在excel VBA中获得自动值,它将显示自动数据1.如果是BOM字母,则将显示2.如果是COM字母,则将显示3.
I want to get automatic value in excel VBA in case I type AOM letter in cell, it will shows automatic data 1. if it is BOM letter, it will shows 2. if it is COM letter, it will shows 3.
例如,AOM = 1,BOM = 2,COM = 3
In example, AOM=1,BOM=2,COM=3
如上所述,如何编写excel vba代码以更改excel单元格中的自动值.
How to write excel vba code to change automatic value in excel cell as condition above.
此致
推荐答案
这可能是
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errhandler
Application.EnableEvents = False
If Target.Value = "AOM" Then Target.Value = 1
If Target.Value = "BOM" Then Target.Value = 2
If Target.Value = "COM" Then Target.Value = 3
continue:
Application.EnableEvents = True
Exit Sub
errhandler:
MsgBox Err.Description
Resume continue
End Sub
将代码放入任何 Sheet对象
.
希望这可以帮助您入门.
Put code in any Sheet Object
.
Hope this gets you started.
这篇关于在Excel VBA中自动获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文