바로 문제의 핵심에 도달 - 대신 =
의 <>
여기에 주요 문제입니다 사용.
은 (c.Value
대신 c.Text
의 사용 @의 arcadeprecinct의 추천은 좋은 생각입니다.)
Excel에서 손으로이 문제를 해결한다면, 당신은 아마 비록 라인 별을 가지 않을 것이다 - 권리? Excel의 기본 제공 필터링을 사용하고 VBA를 사용하면 Range
개체에 AutoFilter
메서드가 내장되어있어 서둘러 똑같은 훌륭한 결과를 얻을 수 있습니다.
Option Explicit
Sub DeleteOthersWithAutoFilter()
Dim r1 As Range, c As Range
'Grab the full data range, not just column H
With Sheets("Sheet2")
Set r1 = .Range(.Cells(1, 1), .Cells(Rows.Count, "N").End(xlUp))
End With
With r1
'Apply the Autofilter method to column H in the range
'identifying any cells NOT containing "<<<Keep Row"
.AutoFilter Field:=8, _
Criteria1:="<><<<Keep Row"
'Clear the remaining, visible rows while keeping the headers
Set c = .Offset(1, 0).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
c.ClearContents
End With
'Clear the filter
Sheets("Sheet2").AutoFilterMode = False
End Sub
Range.AutoFilter
를 사용하는 대신 개별 행을 반복하면 데이터 세트가 커질 특히, 매우 빠르게 할 수 있습니다.
현재 행과 Range.AutoFilter
통해 반복, 두 전략의 차이점에 대해 자세히 알아볼 수 있습니다 :
행동의 각을 벤치마킹 YouTube 동영상을 포함
https://danwagner.co/how-to-delete-rows-with-range-autofilter/
.
Vityata가 답을 주었지만'.Text'를 사용하지 말 것을 추가하고 싶습니다. '.Text'는 실제로 화면에 표시되는 문자열입니다. 따라서 열이 좁아지면''#### ''이되고 모든 것이 삭제됩니다. 대신'.Value'를 사용하십시오. – arcadeprecinct