Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default count instaces of text string in range

hi all,

your thoughts please?

I need to count instances of a text string, in this example "QR",
across my range. However the "QR" may exists within another string
eg. cell A1 - PROJECT 4338567 QR complete
cell a2 - 433756 testing QR

etc

the below is clearly wrong, but it may give you an idea of what I need
to acheive

for each cell in Range(cells(2, 2), Cells(20, 20)).Cells
if cell.value CONTAINS "QR" then
qrcount = qrcount + 1
end if
next
msgbox qrrcount

excel 97

any help appreciated :)
steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default count instaces of text string in range

Steve,
Check out INSTR in the VBA help.
Or you have the worksheet function SEARCH for an Excel solution.

NickHK

"Steve" wrote in message
...
hi all,

your thoughts please?

I need to count instances of a text string, in this example "QR",
across my range. However the "QR" may exists within another string
eg. cell A1 - PROJECT 4338567 QR complete
cell a2 - 433756 testing QR

etc

the below is clearly wrong, but it may give you an idea of what I need
to acheive

for each cell in Range(cells(2, 2), Cells(20, 20)).Cells
if cell.value CONTAINS "QR" then
qrcount = qrcount + 1
end if
next
msgbox qrrcount

excel 97

any help appreciated :)
steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default count instaces of text string in range

nice tip Nick, thanks very much!

my code is now
For Each cell In Range("b12:iv100").Cells
If InStr(1, cell.Value, "QR") 0 Then
qrcount = qrcount + 1
End If
Next

MsgBox qrcount


On Thu, 17 Feb 2005 12:42:32 +0800, "NickHK"
wrote:

Steve,
Check out INSTR in the VBA help.
Or you have the worksheet function SEARCH for an Excel solution.

NickHK

"Steve" wrote in message
. ..
hi all,

your thoughts please?

I need to count instances of a text string, in this example "QR",
across my range. However the "QR" may exists within another string
eg. cell A1 - PROJECT 4338567 QR complete
cell a2 - 433756 testing QR

etc

the below is clearly wrong, but it may give you an idea of what I need
to acheive

for each cell in Range(cells(2, 2), Cells(20, 20)).Cells
if cell.value CONTAINS "QR" then
qrcount = qrcount + 1
end if
next
msgbox qrrcount

excel 97

any help appreciated :)
steve




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default count instaces of text string in range

Steve,
This assumes that "33QRyy jj" and "PROJECT 4338567 QR" are both acceptable.
Is that what you want.

NickHK

"Steve" wrote in message
...
nice tip Nick, thanks very much!

my code is now
For Each cell In Range("b12:iv100").Cells
If InStr(1, cell.Value, "QR") 0 Then
qrcount = qrcount + 1
End If
Next

MsgBox qrcount


On Thu, 17 Feb 2005 12:42:32 +0800, "NickHK"
wrote:

Steve,
Check out INSTR in the VBA help.
Or you have the worksheet function SEARCH for an Excel solution.

NickHK

"Steve" wrote in message
. ..
hi all,

your thoughts please?

I need to count instances of a text string, in this example "QR",
across my range. However the "QR" may exists within another string
eg. cell A1 - PROJECT 4338567 QR complete
cell a2 - 433756 testing QR

etc

the below is clearly wrong, but it may give you an idea of what I need
to acheive

for each cell in Range(cells(2, 2), Cells(20, 20)).Cells
if cell.value CONTAINS "QR" then
qrcount = qrcount + 1
end if
next
msgbox qrrcount

excel 97

any help appreciated :)
steve






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default count instaces of text string in range

set rng = Range("B12:IV100")
msgbox Application.Countif(rng,"*QR*")

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...
nice tip Nick, thanks very much!

my code is now
For Each cell In Range("b12:iv100").Cells
If InStr(1, cell.Value, "QR") 0 Then
qrcount = qrcount + 1
End If
Next

MsgBox qrcount


On Thu, 17 Feb 2005 12:42:32 +0800, "NickHK"
wrote:

Steve,
Check out INSTR in the VBA help.
Or you have the worksheet function SEARCH for an Excel solution.

NickHK

"Steve" wrote in message
. ..
hi all,

your thoughts please?

I need to count instances of a text string, in this example "QR",
across my range. However the "QR" may exists within another string
eg. cell A1 - PROJECT 4338567 QR complete
cell a2 - 433756 testing QR

etc

the below is clearly wrong, but it may give you an idea of what I need
to acheive

for each cell in Range(cells(2, 2), Cells(20, 20)).Cells
if cell.value CONTAINS "QR" then
qrcount = qrcount + 1
end if
next
msgbox qrrcount

excel 97

any help appreciated :)
steve






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
Count one character in a string across a range of cells? Andrea Excel Worksheet Functions 3 February 6th 09 04:33 PM
Count occurance of a leter in a text string justaman Excel Worksheet Functions 3 October 11th 08 04:51 AM
Count Instances of Text in String Q Sean Excel Worksheet Functions 6 February 24th 08 03:15 PM
Sum / count data from text string with delimiter J Excel Worksheet Functions 7 February 21st 07 10:52 PM
Locate and count the recurrences of a text string Trish2 Excel Discussion (Misc queries) 1 March 8th 06 03:02 PM


All times are GMT +1. The time now is 11:41 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"