VBA for Pop Up Message with Condition

rhmkrmi

Active Member
Joined
Aug 17, 2012
Messages
348
Office Version
  1. 365
Platform
  1. Windows
Hi There!

I need a macro to generate a pop-up message when a condition is met.

Thanks!
 
Thank you.
This one work fine.
How can I have more ta one value for "LAB" and also make it not case-sensitive?

Thanks again!
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Not sure what script your saying works fine. There were several posted here.

Do not understand:
How can I have more ta one value for "LAB" and also make it not case-sensitive?


What is ta??

Do you mean more then one?

Do you mean look for LAB or lab or cat or dog or frog and on and on?
 
Upvote 0
Yes, sorry, typo!!

I need to use more than one value, "LAB" "LAB ORD" "OT LAB" and also they will be in upper and lower cases.
 
Upvote 0
Yes, sorry, typo!!

I need to use more than one value, "LAB" "LAB ORD" "OT LAB" and also they will be in upper and lower cases.



I asked this question which you did not answer:

Not sure what script your saying works fine. There were several posted here.
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cel As Range
Set rng = Intersect(Intersect(Target, [H:H,M:M]), Me.UsedRange)
If Not rng Is Nothing Then
    For Each cel In rng
        If InStr(UCase(cel), "LAB") Then
            MsgBox "Enter Rate"
            Exit For
        End If
Next
End If
End Sub
 
Upvote 0
Try this:

Assuming your named Range is "Cake"

It's always easier when you provide specific details like name of Named Range but then you should be able to modify script.
Code:
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  1/17/2019  12:40:25 AM  EST
If Not Intersect(Target, Range("Cake")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If InStr(Target.Value, "LAB") Then MsgBox "Enter Rate"
End If
End Sub
 
Upvote 0
This is the script that worked fine and I need it to be modified to wok for more than one value, e.g. "LAB", "LAB ORD", "OT LAB".


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, cel As Range
Set rng = Intersect(Target,[H:H,M:M])
If Not rng Is Nothing Then
For Each cel Inrng
If InStr(cel,"LAB") Then
MsgBox"Enter Rate"
Exit For
End If
Next
End If
End Sub
 
Last edited:
Upvote 0
Well someone else provided that script so I will just let them help you.

You said you had a named range but I see no named range in this script.
Not sure why my script did not work for you.

Take care.
 
Upvote 0
Your script worked too but only when I enter LAB in single cells.
It does not work when I paste LAB in a range in the column.
Also, how can I add more values than just LAB to your script please?

Thank you for your help.
 
Upvote 0
rhmkrmi - look at post # 15
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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