ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check whether text in cell contains "?" (https://www.excelbanter.com/excel-programming/416327-check-whether-text-cell-contains.html)

H@C0

Check whether text in cell contains "?"
 
Hi,
How can I check with a macro script if the text in a cell contains a
question mark?
Thanks in advance for any tip or hint.
Hans


JLatham

Check whether text in cell contains "?"
 
Use the InStr() function. Example below will tell you if there's a ? in the
text in cell A1 of the active sheet.

Sub HasQuestionMark()
If InStr(Range("A1"), "?") Then
MsgBox "Found question mark"
Else
MsgBox "No question mark here!"
End If
End Sub

"H@C0" wrote:

Hi,
How can I check with a macro script if the text in a cell contains a
question mark?
Thanks in advance for any tip or hint.
Hans



H@C0

Check whether text in cell contains "?"
 
Thanks for your help.
This was exactly what I was looking for.
Hans

On Sat, 30 Aug 2008 12:49:00 -0700, JLatham <HelpFrom @
Jlathamsite.com.(removethis) wrote:

Use the InStr() function. Example below will tell you if there's a ? in the
text in cell A1 of the active sheet.

Sub HasQuestionMark()
If InStr(Range("A1"), "?") Then
MsgBox "Found question mark"
Else
MsgBox "No question mark here!"
End If
End Sub




All times are GMT +1. The time now is 12:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com