读书人

Excel表中如果有些行是标识了颜色就

发布时间: 2012-08-09 15:59:21 作者: rapoo

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表结束,如何实现?


[解决办法]

VB code
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 

读书人网 >VB

热点推荐