Excel表中如果有些行是标识了颜色,就把它隐藏,请问VBA中如何实现?
Sub hiddcolor()
If MsgBox("确定结束任务?", vbYesNo) = vbYes Then
ActiveWindow.LargeScroll ToRight:=-1
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
End Sub
用上述函数来给excel行标识颜色为35,想写另一函数,sheet表从头到尾,如果发现行颜色为35,那么就隐藏该行,至到sheet表结束,如何实现?
[解决办法]
Sub AAA() Dim intRow As Integer Dim intCol As Integer Dim i As Integer Dim j As Integer intRow = UsedRange.Rows.Count intCol = UsedRange.Columns.Count For i = 1 To intRow For j = 1 To intCol If Cells(i, j).Interior.ColorIndex = 35 Then Rows(i).EntireRow.Hidden = True j = intCol + 1 End If Next NextEnd Sub