Страницы: 1
RSS
Работа только с видимыми ячейками
 

Добрый день! Подскажите как можно поправить код чтобы он работал только с видимыми ячейками, а не с тебе что скрыты под фильтром

Код
Sub proba()
    Dim nCol As Integer
    Dim nGr As Integer

    Range("A2:S" & Cells(Rows.Count, 1).End(xlUp).Row).Select    
    nCol = 5    
    Range("A2:S" & Cells(Rows.Count, 1).End(xlUp).Row).Borders.LineStyle = False

    If nCol < 1 Or nCol > Selection.Columns.Count Then Exit Sub

    For r = 1 To Selection.Rows.Count
        If Cells(r, nCol) <> Cells(r + 1, nCol) Then Range(Cells(r, 1), Cells(r, "S")).Select
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 3
            .TintAndShade = 0
            .Weight = xlThin
        End With
    Next r
End Sub
 
Код
Selection.SpecialCells(xlCellTypeVisible)
в помощь
Страницы: 1
Наверх