특정 열의 값을 검사하는 VBA Excel 코드가 있습니다. 해당 열의 행에 'Delete'값이 포함 된 경우 행을 삭제합니다.조건에 따라 행을 제거하는 VBA 느린 프로세스
코드는 제대로 작동하지만 실제로 느립니다. 코드를 빠르게 실행하는 방법에 대한 아이디어가 있습니까?
Dim rng1 As Range
Dim i As Integer, counter As Integer
'Set the range to evaluate to rng.
Set rng1 = Range("g1:g1000")
'initialize i to 1
i = 1
'Loop for a count of 1 to the number of rows
'in the range that you want to evaluate.
For counter = 1 To rng1.Rows.Count
'If cell i in the range1 contains an "Delete"
'delete the row.
'Else increment i
If rng1.Cells(i) = "Delete" Then
rng1.Cells(i).EntireRow.Delete
Else
i = i + 1
End If
Next
감사
다.
감사합니다. Andy,하지만 코드에 문제가 있습니다. 값이 'delete'인 두 개의 후속 항목이있는 경우 첫 번째 항목 만 detet됩니다. 나는 비슷한 것을 시도했다고 생각한다. 어쩌면 Excel 버전 때문일 수도 있습니다. Office 2010을 사용하고 있습니다. – Selrac