Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.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
匹配函数Excel VBA中的相对单元格引用_Vba_Excel - Fatal编程技术网

匹配函数Excel VBA中的相对单元格引用

匹配函数Excel VBA中的相对单元格引用,vba,excel,Vba,Excel,为什么我不能在match函数中使用相对单元格引用?如果我改为使用绝对单元格引用,这将起到预期的作用,但是我需要excel移动到下一行,每个单元格的计算值都在该范围内。例如,第一次迭代比较B29,下一次迭代比较B30,下一次迭代评估B31,依此类推。请帮忙 Sub Test() For Each cell In Worksheets("Sheet1").Range("F29:F50") If Not IsError(Application.Match(RC[-3], Ra

为什么我不能在match函数中使用相对单元格引用?如果我改为使用绝对单元格引用,这将起到预期的作用,但是我需要excel移动到下一行,每个单元格的计算值都在该范围内。例如,第一次迭代比较B29,下一次迭代比较B30,下一次迭代评估B31,依此类推。请帮忙

Sub Test()

    For Each cell In Worksheets("Sheet1").Range("F29:F50")
        If Not IsError(Application.Match(RC[-3], Range("Interior_Lining_Scuffs_Floors"), 0)) Then
            cell.Value = "Interior Lining/Scuffs/Floors"
        End If
    Next
您可以使用这个:

For Each cell In Worksheets("Sheet1").Range("F29:F50")
    If Not IsError(Application.Match(cell.Offset(,-3), Range("Interior_Lining_Scuffs_Floors"), 0)) Then
        cell.Value = "Interior Lining/Scuffs/Floors"
    End If
Next

工作得很好!我知道必须有一个简单的解决办法。非常感谢蒂姆!!!