需要VBA Macro帮助 [英] VBA Macro help needed
问题描述
你好我希望这是有道理的,
我发现这个脚本如果一个单元格中有一个字母或数字,它会在另一个单元格中输入一个值单元格
我想知道如何为此添加多个规则。如果在单元格中输入C或9,那么它会生成句子显示
我希望它显示在不同的单元格而不是相邻的单元格中,并且我希望能够在列表中添加不同的字母以输出不同的价值。
EG
Cell A在A栏中有这个    当宏在E列中运行时的输出
C或9                                         这里的字会出现
HELLO或GOODBYE                             Word1
粉红色或黄色                                         Word2
等等,任何帮助都会很棒并且受到赞赏,因为我对VB和Mac很陌生
Sub CheckValues()
Application.ScreenUpdating = False
With Range(A2,Range(A& Rows.Count).End(xlUp)) .Offset(,1)
.Formula == IF(MIN(FIND({C,9},A2&C9))< = LEN(A2),这里的单词将显示,)
.Value = .Value
以
结束Application.ScreenUpdating = True
End Sub
替换
...偏移(, 1 )
...偏移(, 4 )
获取E栏的输出
对于你的多重条件:
你需要建立一个符合您需求的公式。
实际公式如下:
IF(Condition1,Answer1,empty)
你有3个条件的
需要这样的东西:
IF(Condition1,Answer1,IF(Condition2,Answer2,IF(Condition3,Answer3,empty)))
Hello I hope this will make sense,
I have found this script that if a letter or number is in one cell it will input a value in the another cell
I was wondering how I could add multiple rules to this.At the moment if C or 9 is entered in a cell then it produces the sentence "word here will show up"
I want it to show up in a different cell not the adjacent one, and also I want to be able to add different letter to the list to output different values.
EG
Cell Has This in Column A Output when Macro runs in Column E
C or 9 "word here will show up"
HELLO OR GOODBYE "Word1"
Pink or Yellow "Word2"
Etc, Any help would be great and appreciated as I am very new to VB and Macros
Sub CheckValues() Application.ScreenUpdating = False With Range("A2", Range("A" & Rows.Count).End(xlUp)).Offset(, 1) .Formula = "=IF(MIN(FIND({""C"",9},A2&""C9""))<=LEN(A2),""word here will show up"","""")" .Value = .Value End With Application.ScreenUpdating = True End Sub
replace
...Offset(, 1)
with
...Offset(, 4)
to get output in column E
For your multiple condition:
your need to build a formula that match your needs.
Actual formula is in the form:
IF(Condition1, Answer1, empty)
for 3 conditions you need something like:
IF(Condition1, Answer1, IF(Condition2, Answer2, IF(Condition3, Answer3, empty)))
这篇关于需要VBA Macro帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!