Hi,
I have a macro in one file which uses an input box where the user types in a subcontractor code to retrieve address and contact details from another file.
If the user inputs the incorrect subcontractor code, an error message box pops up. Currently the user then has to select a button in the original file to restart the macro at the input box stage.
What I want to happen is when ok is selected on the error message, to return to the input box so in my macro below where the error message says "An error occurred - you asked for a subcontractor that does not exist. Please try again." and the user selects OK, I would like it to return to the 'Enter the Subcontractor line and the "Please enter the Subcontractor code" input box reappears.
Have searched everywhere but with my limited skills still not resolved.
Any ideas?
![]()
Sub Supplier() 'obtain subcontractor details Dim ordSubcontractor Dim Subcontractor 'Enter the Subcontractor Subcontractor = InputBox( _ prompt:="Please enter the Subcontractor Code.") 'goto subcontractor and address workbook and find details Application.ScreenUpdating = False On Error GoTo AddressError Windows("ORDADDSS.XLS").Activate ordSubcontractor = Range(Subcontractor) 'write address to order Application.ScreenUpdating = True Windows("SUBCONTRACT ORDER.XLS").Activate Range("ordsubcontractor") = ordSubcontractor GoTo endsub 'if error occurs finding address file or references AddressError: Application.ScreenUpdating = True Windows("SUBCONTRACT ORDER.XLS").Activate MsgBox "An error occured - you asked for a subcontractor " & _ "that does not exist. Please try again." endsub: End Sub
Bookmarks