所以我需要一个可以执行以下操作的脚本:
此外,我需要此规则将相应的行输入到500(如果单元格B3 = Duck,则C3,D3和E3受影响)。
感谢您的帮助!我没有太多的经验,所以任何帮助将不胜感激。
答案 0 :(得分:2)
将其放入C2并在列表中上下复制:
=IF(MATCH($B2,{"Dog","Bear","Duck"},0)>=COLUMN(A:A),NA(),"")
如果您想要字符串n/a
,请在公式
"n/a"
代替NA()
vba解决方案:
Sub fillNA()
Dim lookupArr(1 To 3, 1 To 2) As Variant
Dim i&, j&
lookupArr(1, 1) = "Duck"
lookupArr(1, 2) = 3
lookupArr(2, 1) = "Bear"
lookupArr(2, 2) = 2
lookupArr(3, 1) = "Dog"
lookupArr(3, 2) = 1
With ActiveSheet
For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
For j = LBound(lookupArr, 1) To UBound(lookupArr, 1)
If .Cells(i, 2) = lookupArr(j, 1) Then
.Cells(i, 3).Resize(, lookupArr(j, 2)).Value = "N/A"
Exit For
End If
Next j
Next i
End With
End Sub
答案 1 :(得分:0)
If Range("B2") = "Duck" Then Range("C2,D2,E2")="n/a"