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.
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,078
Messages
5,599,632
Members
414,326
Latest member
kfg1287

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