LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checking if a cell contains a string that is not case sensitive

This count you are doing... it is in a single cell, right? If so, this
function should do what you want...

Function CountTextInCell(CellText As String, TextToCount As String) As Long
If Len(CellText) = 0 Then Exit Function
CountTextInCell = (Len(CellText) - Len(Replace(CellText, TextToCount, _
"", , , vbTextCompare))) / Len(TextToCount)
End Function

Just pass in the text from the cell. For example...

Sub Test()
MsgBox CountTextInCell(Sheet2.Range("A1").Value, "abc")
End Sub

Rick


"Colin Hempsey" wrote in message
...
I am trying to count how many times a specific string "abc" forms part of a
cell in a spreadsheet.

For example

abcgfd, abcdse, efgabc would be vaild and I would like to count these

abdcef, bcadef, cbaeds would not be valid and I would not want to count
these.

Can anyone help point me in the right direction?

Thanks.


 
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
Case Sensitive Lookup danpt Excel Discussion (Misc queries) 3 May 14th 09 06:20 AM
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
Case sensitive and single character in cell praveen_khm[_22_] Excel Programming 0 February 7th 06 02:21 PM
Case Sensitive w/ IF jeffP Excel Worksheet Functions 11 February 6th 06 01:16 AM
.Name case sensitive CinqueTerra Excel Programming 2 January 16th 06 08:57 PM


All times are GMT +1. The time now is 06:43 PM.

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

About Us

"It's about Microsoft Excel"