Yodelayheewho
Member
I'm a beginner when it comes to VBA. I have a worksheet with 122 columns, so sending a sample is not possible. I'm hoping the error in the code will be easy for an expert to spot without the data.
To help manage this growing worksheet, I created a VBA Userform and so far it is fantastic!
My VBA userform includes a Delete Order Button. When clicked it performs two actions. Action1. It deletes the record selected in the worksheet (titled: "Master") and Action2. It clears the userform. Action2 is working fine (I only included 5 out of 122 lines of code here). Action1 is not working. Does anyone have insight on why?
Legend
Worksheet title: "Master"
First row of data: Row 3
Columns: A-DR
Action1
'Delete Order Button'
>>> use code - tags <<<
To help manage this growing worksheet, I created a VBA Userform and so far it is fantastic!
My VBA userform includes a Delete Order Button. When clicked it performs two actions. Action1. It deletes the record selected in the worksheet (titled: "Master") and Action2. It clears the userform. Action2 is working fine (I only included 5 out of 122 lines of code here). Action1 is not working. Does anyone have insight on why?
Legend
Worksheet title: "Master"
First row of data: Row 3
Columns: A-DR
Action1
'Delete Order Button'
>>> use code - tags <<<
Code:
Private Sub DeleteOrder_Click()
Dim Shop_Order_Number As String
Shop_Order_Number = Trim(TextShopOrderNumber)
lastrow = Worksheets("Master").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Master").Cells(i, 1).Value = Shop_Order_Number Then
Worksheets("Master").Rows(i).Delete
End If
'' Action2
Next 'The following code clears the textboxes and is working'
TextShopOrderNumber = ""
TextPrefix = ""
TextE10Status = ""
TextSuffix = ""
TextEmailSubjectLine = ""
End Sub
Last edited by a moderator: