I have a userform which I use to track equipment repair history.
The userform is comprised of the following items
Textbox for RMA number: txtPORMA
Textbox for PO number: txtPO
Textboxes for Serial numbers: txtPOSerial1 - txtPOSerial14
Textboxes for Cost on the PO: txtCost1 - txtCost14
Textboxes for the reason of the repair: txtReason1 - txtReason14
Checkboxes if the serial number will be added to the PO: chkPOSerial1 - chkPOSerial14
Command Button to submit the changes: btnAddPO
What happens is that a user puts in an RMA number and the form finds all the corresponding serial numbers that go with it which are stored on the spreadsheet. Not every serial number will be added to the PO because it might be covered under warranty. So here the user would check the checkbox if the serial number is going to be added to the PO. When they click the submit button it updates the PO number on the spreadsheet.
I'm currently using the following code to find the RMA number, find the matching serial number, and then find if the user has checked the box and then add the po, cost and reason.
Sometimes there may only be 1 serial number to an RMA but there could be as many as 14. Each serial number is stored on a separate line on the spreadsheet.
As you can see, whats in red is basically repeated 14 times, one for each serial number and check box box. I keep thinking there has to be a way to eliminate these similar If statements, I'm just not sure how.
I do use this same method for other things on the userform so I'm hoping that if I can find a way to do it here, that I can use it in other places as well.
Thank you!
Bookmarks