VBA Macro to show a message If a cell string contains a character

krm974ynk

New Member
Joined
Jul 29, 2021
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
I need a VBA code to check a cell and If cell text contains a specific character such as: ! (exclamation mark) it will show a message box.
such as, presume cell string is: "January!" and then to show a message. If cell string is: "January" not to show a message.

I appreciate ıf anyone can help me.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,
You can test following
VBA Code:
Sub Test()
MsgBox IIf(InStr(1, ActiveCell, "!") > 0, "YES", "N0")
End Sub
 
Upvote 0
Hi James, thank you for the help. Unfortunately id did not work. Maybe I made a mistake I am not so sure.
 
Upvote 0
Hi James, I have arranged as follows and it works at the moment. When there is: "!!!" inside string I get message....

If InStr(1, ActiveCell.Value, "!!!") <> 0 Then
MsgBox "CAUTION!"
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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