03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have a simple userform that contains one textbox named txt_unitnumber. I am trying to delete ALL rows (there could be 5-50 rows) on worksheet "data" that contain the unit number in column N. I have put together this code and I do not get any errors when I execute the delete button, but it does not delete the expected rows.
1. how do I get this code to work? The unit number in column N is formatted a "general" if that matters!
2. my data table is large, and would like the code to look from the bottom up, instead of the top down, how would I do that. - I understood from research that would speed up the macro.
Your help is greatly appreciated.
1. how do I get this code to work? The unit number in column N is formatted a "general" if that matters!
2. my data table is large, and would like the code to look from the bottom up, instead of the top down, how would I do that. - I understood from research that would speed up the macro.
Your help is greatly appreciated.
Code:
Private Sub cmd_delete_Click()
Dim ws As Worksheet
Set ws = Worksheets("data")
' Edit database
Set rngfind = ws.Range("N:N").Find(what:=Me.txt_unitnumber.Value, MatchCase:=True)
If Not rngfind Is Nothing Then
rngfind.EntireRow.Delete
End If
ClearUnitNumber
End Sub