#1   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default Search

Hello,

I am stuck and cannot remember how to do this...

I would like to perform an if statement that:

if (the current cell has a "C" character somewhere within it) then
........Perform an action......
elseif (it does not) then
..........perform another action.......
endif

What statement do I need to use to determine if a "C" is a character
anywhere in the cell. I remember how to use the Left, Right and Mid
functions, but I cannot remember how to use the Search function in this
manner. What would be the best way to go about doing this?

Thank You,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Search

Hi,
Try this :

Sub test()

Dim stringtosearch As String
Dim stringtofind As String

stringtosearch = "ABCDEFG"
stringtofind = "C"

If InStr(1, stringtosearch, stringtofind) < 0 Then
MsgBox "C found" ' Add found logic.....
Else
MsgBox "C not found" ' Add not found logic ....
End
End If

End Sub

HTH

"tjh" wrote:

Hello,

I am stuck and cannot remember how to do this...

I would like to perform an if statement that:

if (the current cell has a "C" character somewhere within it) then
.......Perform an action......
elseif (it does not) then
.........perform another action.......
endif

What statement do I need to use to determine if a "C" is a character
anywhere in the cell. I remember how to use the Left, Right and Mid
functions, but I cannot remember how to use the Search function in this
manner. What would be the best way to go about doing this?

Thank You,

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two search category & two search terms avk Excel Discussion (Misc queries) 1 June 2nd 10 01:25 PM
file search or search files Richad Excel Discussion (Misc queries) 0 October 22nd 09 07:56 PM
Functions (search within search result) reply to this please Nick Excel Worksheet Functions 1 February 17th 09 03:57 AM
How do I search excel spreadsheets using multiple search criteria. Kasper Excel Worksheet Functions 4 December 15th 05 12:26 AM
Create a search Field within a worksheet to search command buttons Ed P[_2_] Excel Programming 1 December 14th 04 08:04 PM


All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"