Prevent message from popping up twice

gdome

New Member
Joined
Sep 29, 2009
Messages
17
I want to prompt the user with an error message if they have entered too many categories in their selection. My current code is as follows:

If Range("F44") <> "" And WorksheetFunction.CountA(Range("F6:F15")) = 10 Then
MsgBox "You can only enter a maximum of 9 categories if this is selected. Please delete one of the categories above."
Range("F15").Select​
End If

Now, this works fine but the problem is that the error message pops up again when the macro selects F15.

Is there a way to prevent the message from popping up when F15 is automatically selected?

Thanks!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Maybe

Code:
Application.EnableEvents = False
before the selection command and

Code:
Application.EnableEvents = True
after the selection command?
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,921
Latest member
BBQKING

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