728x90

특정 글자색이 포함된 셀이 아닌 행은 전부 삭제하는 VBA 코드다.


Sub StringColor_delete()
    Dim r As Double
    Dim LastRow As Double  '// 마지막 행의 변수
   
    Application.ScreenUpdating = False
    Debug.Print Cells(7, 1).Font.ColorIndex  '// 글자색 알아내기   
    LastRow = Cells(Rows.Count, "A").End(3).Row
   
    For r = LastRow To 1 Step -1   '// 삭제는 마지막행부터 역순으로
        If Cells(r, "A").Font.ColorIndex <> 50 Then  '// 알아낸 색상과 다른 셀이면
            Cells(r, "A").EntireRow.Delete  '// 그 셀이 포함된 행을 전부 삭제해라.
        End If
    Next r
  
End Sub


블로그 이미지

Link2Me

,