How can I allow a user to correct excel data once VBA identifies an error?

Chopper50

New Member
Joined
Mar 14, 2013
Messages
30
I have a message box pop up when VBA encounters an error, however once the user clicks OK the error handler skips the line and moves on. I want to give the user the opportunity to correct what is causing the error and give the program the chance to rerun that portion of the program.

ErrorHandler:
ActiveSheet.Cells(i, Z1).Select
MsgBox ("Issue is in row " & i)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I have a message box pop up when VBA encounters an error, however once the user clicks OK the error handler skips the line and moves on. I want to give the user the opportunity to correct what is causing the error and give the program the chance to rerun that portion of the program.

ErrorHandler:
ActiveSheet.Cells(i, Z1).Select
MsgBox ("Issue is in row " & i)

Look up the "Resume Statement" in the VB help files... I think it is what you are looking for.
 
Upvote 0
I missed the Resume Next in my code. So it is actually

ErrorHandler:
ActiveSheet.Cells(i, Z1).Select
MsgBox ("Issue is in row " & i)
Resume Next

But as soon as i click ok on the message box, the code continues on without any user adjustments
 
Upvote 0
Something like

Code:
ErrorHandler:
    Dim userEntry as Variant
    With Cells(i, Z1)
        .Select
        Do 
            userEntry = InputBox("Fix this number", Default:=.Value, type:=7)
            If TypeName(userEntry) = "Boolean" And userEntry = False then Beep
        Loop Until TypeName(userEntry) <> "Boolean" Or userEntry <> False
        .Value = userEntry
    End With
    Resume Next
 
Upvote 0
I'm giving this a try. I get a Compile error "Named argument not found" on the userEntry line at the --- type:=7 ---- portion.
 
Upvote 0
:oops:Try this
Code:
userEntry = [U]Application[/U].InputBox("Fix this number", Default:=.Value, type:=7)
 
Upvote 0

Forum statistics

Threads
1,215,588
Messages
6,125,692
Members
449,250
Latest member
azur3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top