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!
 
Thanks footoo.

So, I post # 15, how can I add more values in If InStr(UCase(cel), "LAB") Then
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If you mean like this :
I need to use more than one value, "LAB" "LAB ORD" "OT LAB" and also they will be in upper and lower cases.
The code already can handle it. Why don't you try?
 
Upvote 0
Of course you are right in that it works because they all have "LAB" in them but what if I want to include "LEAVE" in the code as well?

I try the following syntax but it does not work:

If InStr(UCase(cel), ["LAB"], ["LEAVE"]) Then
 
Last edited:
Upvote 0
Did you actually try the script provided. The script provided works for me.

Instr takes care of it.

With Instr all you need is like George

And Instr will find George George and Jane George has a Cat

On and on.
 
Last edited:
Upvote 0
Yes, the script in post # 15 works for anything that has "LAB" in it, no problems there.
I need to include more words in the condition, like "LEAVE" as well as "LAB" and do not know how to do that.

Thank you.
 
Upvote 0
How many words?
Are you talking about 2 or 3 different words or 10 or 20 ?

If it's more then 2 or 3 we need to take a different approach.



Yes, the script in post # 15 works for anything that has "LAB" in it, no problems there.
I need to include more words in the condition, like "LEAVE" as well as "LAB" and do not know how to do that.

Thank you.
 
Upvote 0
I worked this out:

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") Or InStr(UCase(cel), "LEAVE") Then
MsgBox "Enter Rate"
Exit For
End If
Next
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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