osevero
11-10-2013, 10:04 PM
Hello everyone!
I need help. I intend to use a form to delete a row from the number that is written in the textbox. You can see here the example: 10806
I wrote this code but it isn't well developed.
Private Sub CommandButton1_Click()
ThisWorkbook.Worksheets("Sheet1").Activate
Range("B8").Select
While ActiveCell <> ""
If TextBox1.Text = ActiveCell Then
Reply = MsgBox(" Number found. Are you sure you want to delete?", 3, " Delete ")
While ActiveCell = TextBox1.Text
ActiveCell.EntireRow.Delete
Wend
End If
ActiveCell.Offset(1, 0).Activate
Wend
With Sheets("Sheet1")
Range("B7:B8").Value = WorksheetFunction.Transpose(Array(1, 2))
Range("B7:B8").AutoFill Destination:=.Range("B7:B" & .Range("C" & .Rows.Count).End(xlUp).Row), Type:=xlFillDefault
End With
End Sub
What I need:
-The code has to search in the ID column, the number that is written in the textbox and delete that row.
-If the number is found then a message should appear: "ID found, are you sure you want to delete?" Option: Yes or no. If the answer is "Yes" then the row is deleted. If the answer is "No", then the message box disappears.
-If not found, the ID column, the number entered in the textbox, then a message appears: "The number was not found." Option: Ok
I need help. I intend to use a form to delete a row from the number that is written in the textbox. You can see here the example: 10806
I wrote this code but it isn't well developed.
Private Sub CommandButton1_Click()
ThisWorkbook.Worksheets("Sheet1").Activate
Range("B8").Select
While ActiveCell <> ""
If TextBox1.Text = ActiveCell Then
Reply = MsgBox(" Number found. Are you sure you want to delete?", 3, " Delete ")
While ActiveCell = TextBox1.Text
ActiveCell.EntireRow.Delete
Wend
End If
ActiveCell.Offset(1, 0).Activate
Wend
With Sheets("Sheet1")
Range("B7:B8").Value = WorksheetFunction.Transpose(Array(1, 2))
Range("B7:B8").AutoFill Destination:=.Range("B7:B" & .Range("C" & .Rows.Count).End(xlUp).Row), Type:=xlFillDefault
End With
End Sub
What I need:
-The code has to search in the ID column, the number that is written in the textbox and delete that row.
-If the number is found then a message should appear: "ID found, are you sure you want to delete?" Option: Yes or no. If the answer is "Yes" then the row is deleted. If the answer is "No", then the message box disappears.
-If not found, the ID column, the number entered in the textbox, then a message appears: "The number was not found." Option: Ok