[VBA] Error Message

ExcelNooberino

New Member
Joined
Jan 2, 2019
Messages
43
Office Version
  1. 2016
Platform
  1. Windows
So I've been working on a macro for my personal use really and I added some errors with MsgBoxes to prevent myself from making a silly mistake. The thing is I have two different erros in a row (consecutive errors) and I want to show just one of the MsgBoxes. Instead of that I'm getting one MsgBox from the first error and when I close that box the second one appears as well. The thing is I want to show just the first one if the first error is to occur. So far I got this:

Dim ws As Worksheet

On Error Resume Next
Set ws = Sheets("Sheet1")
If Err.Number <> 0 Then
MsgBox "Please import data first", vbInformation, "Importing Error"
Else
'do nothing
End If


If Range("Weekly!G19") = "" Then
MsgBox "Please fill the Obsolete Inventory box!", vbInformation, "Generating Error"
End
Else
'do nothing
End If

Any suggestions?! :rolleyes:
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi again! So, I realized that exiting the sub would fix the problem with the two MsgBoxes showing up, but now the second error I should get doing something is not occurring.. In simple words, even if Range("Weekly!G19") = "" this secong MsgBox doesn't show up :/
 
Upvote 0
Nevermind, I was posting the Exit Sub after the End If and not after the MsgBox.. It works now, thank you :stickouttounge:
 
Upvote 0

Forum statistics

Threads
1,223,992
Messages
6,175,822
Members
452,672
Latest member
missbanana

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