message box in vba when range is less then.. vba in the sheet itself - view code

amit96

New Member
Joined
Feb 15, 2022
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
How do I do the code in the sheet itself in the "view code"
when the value in column K (any row in the column) is less than 10,
a message will pop up to the screen that says - "10 days left until expiration"

I would appreciate your assistance!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
@amit96 Maybe like below.

VBA Code:
If Evaluate("Countif(K:K,""<10"")") > 0 Then MsgBox "10 days left until expiration"

How you might trigger it will depend upon the way you are inputting / editing your data.
If an identifiable direct manual input affects it then you could use the Worksheet_Change event.
Simple example of which might be.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'ignore if not column K
If Not Target.Column = 11 Then Exit Sub
'check for vals < 10
If Evaluate("Countif(K:K,""<10"")") > 0 Then MsgBox "10 days left until expiration"

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

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