View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default COUNTIF "string" in cell

Sub countjohn()
For Each c In Selection
If InStr(UCase(c), "JOHN") 0 Then mc = mc + 1
Next c
MsgBox mc
End Sub

--
Don Guillett
SalesAid Software

"CLR" wrote in message
...
Thanks Don..........works good but seems to be "case sensitive".......can
anything be done to change that?

Vaya con Dios,
Chuck, CABGx3



"Don Guillett" wrote:

something like
mc=0
for each c in selection
if instr(c,"John")0 then mc=mc+1
next c
msgbox mc
--
Don Guillett
SalesAid Software

"CLR" wrote in message
...
Hi All.......
How might the code read to perform a check of all cells in the selected
column and count all the cells which contain a certain string at least
once,
and place the total in cell B1. That is, if the string exists by
itself,
or
within a string of other characters in the same cell.....and if
multiple
times in one cell, only count once.

If looking for JOHN,
Cell with JOHN ...would count 1
Cell with JOHN/BILL /TOM & OTHERS... would count 1
Cell with JOHN / BILL,JOHN ...would count 1
Cell with BILL, TOM ...would not count
(note the inconsistant punctuation)

TIA for any help
Vaya con Dios,
Chuck, CABGx3