2014-11-26 3 views
0

사용자가 입력 한 값에 대해 작은 범위의 값을 확인하려고합니다. 쿼리는 범위를 통해 반복되지만 ActiveCell.EntireRow.Clear 줄은 절대로 히트하지 않습니다. 내 코드는 어떤 아이디어입니까?사용자 입력 VBA에 대해 셀 범위 확인

Private Sub CommandButton3_Click() 
Dim iLastRow As Long 
Dim i As Long 
Dim myValue2 As String 
myValue2 = InputBox("Enter Last Name:") 

With ActiveSheet 

    iLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row 
    For i = 33 To iLastRow 
     If ActiveCell.Value = myValue2 Then 
    ActiveCell.EntireRow.Clear 

    Else 

    End If 
     Next i 

End With 

End Sub 

답변

0

당신이를 ActiveCell 필요하지 않습니다 : 완벽하게 작동

Private Sub CommandButton3_Click() 
    Dim iLastRow As Long 
    Dim i As Long 
    Dim myValue2 As String 
    myValue2 = InputBox("Enter Last Name:") 
    With ActiveSheet 
     iLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row 
     For i = 33 To iLastRow 
      If Cells(i, "B").Value = myValue2 Then 
       Cells(i, "B").EntireRow.Clear 
      End If 
     Next i 
    End With 
End Sub 
+0

이 - 정말 감사합니다! – Savino

관련 문제