[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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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 :p
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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