Thread: DELETING ROW
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default DELETING ROW

This will work. It needs modified if the value could be found more
than once and you want to delete all instances.

Dim miRow As Long

Private Sub CommandButton1_Click()
If miRow = 0 Then Exit Sub
If Label2 = "Found!" Then
Sheets("Sheet1").Rows(miRow).Delete
Label2 = ""
End If
miRow = 0
End Sub

Private Sub TextBox1_AfterUpdate()
Dim iFind As Integer

iFind = TextBox1.Value
Do
miRow = miRow + 1
If iFind = Sheets("Sheet1").Range("A" & miRow) Then
Label2.Caption = "Found!"
Exit Sub
End If
Loop Until Sheets("Sheet1").Range("A" & iRow + 1) = ""
Label2 = "Not found."
End Sub

Hth,
Merjet