PDA

View Full Version : [SOLVED] URGENCY Please: Delete a row by a textbox



osevero
11-14-2013, 09:29 PM
Hi!

Please help! : pray2:


So I have a form with a textbox to delete a row through the ID number, but when I delete the row, the ID numbers should always be aligned numerically (1,2,3,4). For this I use a function in the cells of the ID column like =IF(D7<>"",ROW()-6,"") The problem is that using the code I'm using to delete the row, it never finds the ID number to delete. I dont know why! The code is this:


Private Sub CommandButton1_Click()

Dim WHAT_TO_FIND As String
Dim WS As Excel.Worksheet
Dim FoundCell As Excel.Range

WHAT_TO_FIND = Delete.TextBox1.Value

Set WS = ActiveSheet
Set FoundCell = WS.Range("B7:B2000").Find(what:=WHAT_TO_FIND, lookat:=xlWhole)
If Not FoundCell Is Nothing Then
If MsgBox("ID found, are you sure you want to delete?", vbYesNo) = vbYes Then
FoundCell.EntireRow.Delete
Else
Unload Me
Exit Sub
End If
Else
MsgBox (WHAT_TO_FIND & " " & "The number was not found.")
End If

End Sub

Somebody help me!

Are also trying to help me on this forum: http://www.excelforum.com/excel-programming-vba-macros/968634-urgency-please-delete-a-row-by-a-textbox.html

SamT
11-15-2013, 01:12 PM
Solved at excelforum 25 minutes ago.