我想遍历第一行的每一列,如果在列标题中找到 Job,那么我需要遍历该列的每个单元格,如果单元格值小于 5,则为整行着色。这就是我正在尝试但失败的方法:
Sub rr()
Dim a, i, col As Integer
Dim r As Range
r = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
a = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a Step 1
For col = 1 To r Step 1
If Cells(1, col).Value = "job" Then Cells(1 + 1, col).Activate
For Each cell In r
If r.Value <= 5 Then ActiveSheet.Range(Cells(2, 1), Cells(2, r)).Interior.ColorIndex = 38 Else: Selection.Offset(1, 0).Selection
Next c
Next col
Next i