如何在将列的单元格的值与字符串进行比较时排除列的活动单元格的第一个单元格
How to exclude first cell of the active cells of a column while comparing the values of the cells of the column with a string
如何排除 C 列的第一个单元格 i,e header
Sub test()
Dim MySht As Worksheet
Dim MyRng As Range
Set MySht = ThisWorkbook.Sheets("Sheet1")
Set MyRng = MySht.UsedRange.Columns("C")
For Each cell In MyRng.Cells
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
Next
End Sub
如果我没有正确理解你的问题,你想跳过范围的第 1 行。在这种情况下,您可以按如下方式修改 for 循环:
For Each cell In MyRng.Cells
If cell.Row != 1 Then
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
End If
Next
如何排除 C 列的第一个单元格 i,e header
Sub test()
Dim MySht As Worksheet
Dim MyRng As Range
Set MySht = ThisWorkbook.Sheets("Sheet1")
Set MyRng = MySht.UsedRange.Columns("C")
For Each cell In MyRng.Cells
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
Next
End Sub
如果我没有正确理解你的问题,你想跳过范围的第 1 行。在这种情况下,您可以按如下方式修改 for 循环:
For Each cell In MyRng.Cells
If cell.Row != 1 Then
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
End If
Next