在范围(80行,7列)中查找一个范围(7个单元格)



每次在myRange中找到7个灰色单元格(在一行上(时,我想增加一个计数器(变量x(:80行x 7列我真的不知道从哪里开始,那么任何想法都是受欢迎的。

Dim rCell  As Range
For Each rCell In myRange
' Looking for grey cells, the whole line of 7 days
If rCell.Interior.Color = RGB(200, 200, 200) Then
' something like that
'If the 7 cells in a row are grey then x = x + 1
End If
Next rCell

如果你能给我指明正确的方向,那就太好了。有可能用7个细胞取代rCell吗?

感谢

Dim rCell  As Range, rw as range, n as long
For Each rw in myRange.Rows   'loop over rows
For Each rCell In rw      'loop cells in row  
If rCell.Interior.Color = RGB(200, 200, 200) Then n = n + 1
If n = 7 Then 
x = x + 1
n = 0  'reset counter
End If 
Next rCell
Next rw

相关内容

最新更新