macro to create warning popup if a condition is true

fingermouse

Board Regular
Joined
Dec 13, 2013
Messages
117
Hi,

I've been asked to with find a macro-based solution to the following task, hope someone can help.

On an Excel worksheet, I have a range of cells within a column. For example, A2:A30.

In each of these cells there's a numerical value.

In column B of the same worksheet , I have a drop down list with 4 user options. The list applies to cells B2:B30.

The options are 'Compulsory' Voluntary' 'None' and 'Not applicable'

If a value in a column A cell is less than 250,000 (0 to 24,999) the user cannot select 'Compulsory' in the corresponding cell in column B. if the user attempts to do so, I want a pop-up message which states "threshold not met - please select 'none'. "

is this possible? Any help very much appreciated.

Thanks, Cal.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
Hi Cal, try this in the sheet module

Howard

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Intersect(Target, Range("B2:B30")) Is Nothing Then Exit Sub
   If Target.Count > 1 Then Exit Sub
   
   If Target.Offset(, -1).Value < 250000 And Target.Value = "Compulsory" Then
     MsgBox "Threshold not met - please select ""none"""
     
     Target.ClearContents
     Target.Activate
     Exit Sub
   End If
    
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,008
Messages
5,834,852
Members
430,324
Latest member
bosphoruskid

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
Top