VBA - 通过sub For / If语句循环

时间:2017-08-15 14:41:40

标签: excel vba excel-vba

我无法循环查看此data

的For语句
Dim c As Range, color As Integer, y As Integer
Sheets("Point Names").Select
numpts = Range("A2", Range("A2").End(xlDown)).Rows.Count
y = x
With Sheets("Reporting")
    For y = 1 To numpts
        Set c = Range("C" & (12 * y - 2))
        For color = c To Range(c, Range(c).End(xlToRight)).Columns.Count
            If Cells(color).FormulaR1C1 = "=Abs(R[-2]C-R[-1]C)/R[-1]C)" _
            > ToleranceMean * ActiveCell.Offset(-1, 0) Then
                Cells(color).Interior.color = RGB(255, 0, 0)
            End If
        Next color
    Next y
End With

我的目标是让每个位于公差范围之外的单元格在行Change in Temp中为红色。

提前致谢。

1 个答案:

答案 0 :(得分:1)

我发现该代码存在很多问题,但可能首先要解决的问题是:您正在选择工作表"Point Names"(为什么选择它?不需要它),使用带有工作表(“报告”) ) - 声明但在with内您没有使用with的任何内容。您的所有代码都使用活动工作表,这可能不是您想要的。你必须写.cells.Range(注意前导点)

相关问题