Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 循环数组中的所有内容以与每个单元格进行比较_Vba_Excel - Fatal编程技术网

Vba 循环数组中的所有内容以与每个单元格进行比较

Vba 循环数组中的所有内容以与每个单元格进行比较,vba,excel,Vba,Excel,在转到下一个单元格之前,如何让数组中的所有值对单元格进行评估 数组中的采样值 不适用 目前它只是读一次然后继续 for b =1 to 9 ' it starts replacing after i added this code For Each cel In SrchRnga If InStr(1, cel.Value, BOM(b )) > 0 Then cel.Offset(

在转到下一个单元格之前,如何让数组中的所有值对单元格进行评估

数组中的采样值 不适用

目前它只是读一次然后继续

for b =1 to 9  ' it starts replacing after i added this code
        For Each cel In SrchRnga

                    If InStr(1, cel.Value, BOM(b )) > 0 Then
                        cel.Offset(0, 1).Value = SAP(b)
                        cel.Offset(0 + 9, 1).Value = UF(b)

                    End If
        Next cel
next b
我尝试在外部放置一个for循环,认为它将读取单元格8次,但这会将数组中不存在的所有值替换为

我想知道的是:
如何为每个单元格循环数组,而不替换数组中不存在的值。

将迭代器放入for each循环中

For Each cel In SrchRnga
    For b = 1 to 9        
        If InStr(1, cel.Value, BOM(b )) > 0 Then
            cel.Offset(0, 1).Value = SAP(b)
            cel.Offset(0 + 9, 1).Value = UF(b)
        End If
    next b
Next cel

它在哪里取代价值观?只有当它匹配时,你才会做一些事情。SAP和UF的内容是什么?我编辑了我的问题。我不确定为什么添加“for循环”会将我的所有值替换为“”
For Each cel In SrchRnga
    For b = 1 to 9        
        If InStr(1, cel.Value, BOM(b )) > 0 Then
            cel.Offset(0, 1).Value = SAP(b)
            cel.Offset(0 + 9, 1).Value = UF(b)
        End If
    next b
Next cel