Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Case Sensitive Lookup | Excel Discussion (Misc queries) | |||
countif function: how to distinguish case/make case sensitive | Excel Worksheet Functions | |||
Case sensitive and single character in cell | Excel Programming | |||
Case Sensitive w/ IF | Excel Worksheet Functions | |||
.Name case sensitive | Excel Programming |