Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Code line not calculating correctly

strSearchString = InputBox(Prompt:= _
"Enter a title or other value to search for.", _
Title:="Search Workbook") ' Say I enter zoo

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "=" &
strSearchString) 'problem line see below
Next ws
---------------------------------------------------

On Sheet1 c1 = zoo d4 = go to zoo e10 = zoo << above code
only counts 2 on Sheet1
On sheet 2 g4 = Where is zoo h10 = zoo << above
code only counts 1 on Sheet2
On Sheet3 b3 = zoo h4 = zoo <<
above code only counts 2 on Sheet3

How must I modify countif() above to include zoo when it is within or a part
of cell, but not exclusively?

Using Edit, Find does OK, it finds 3 on Sheet1; 2 on Sheet2 and 2 on Sheet3
Confused...
TIA,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code line not calculating correctly

=countif(Range,"*zoo*")

would do what you want, so you need to modify your code to produce that

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "*" & _
strSearchString & "*") 'problem line see below
Next ws

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:r0_ud.3987$jn.2066@lakeread06...
strSearchString = InputBox(Prompt:= _
"Enter a title or other value to search for.", _
Title:="Search Workbook") ' Say I enter

zoo

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "=" &
strSearchString) 'problem line see below
Next ws
---------------------------------------------------

On Sheet1 c1 = zoo d4 = go to zoo e10 = zoo << above code
only counts 2 on Sheet1
On sheet 2 g4 = Where is zoo h10 = zoo << above
code only counts 1 on Sheet2
On Sheet3 b3 = zoo h4 = zoo

<<
above code only counts 2 on Sheet3

How must I modify countif() above to include zoo when it is within or a

part
of cell, but not exclusively?

Using Edit, Find does OK, it finds 3 on Sheet1; 2 on Sheet2 and 2 on

Sheet3
Confused...
TIA,





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Code line not calculating correctly

Thanks Tom; I got it going...
with:

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, _
"=" & "*" & strSearchString & "*")
Next ws

"Tom Ogilvy" wrote in message
...
=countif(Range,"*zoo*")

would do what you want, so you need to modify your code to produce that

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "*" & _
strSearchString & "*") 'problem line see below
Next ws

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:r0_ud.3987$jn.2066@lakeread06...
strSearchString = InputBox(Prompt:= _
"Enter a title or other value to search for.", _
Title:="Search Workbook") ' Say I enter

zoo

For Each ws In Worksheets
countTot = countTot + Application.CountIf(ws.UsedRange, "=" &
strSearchString) 'problem line see below
Next ws
---------------------------------------------------

On Sheet1 c1 = zoo d4 = go to zoo e10 = zoo << above

code
only counts 2 on Sheet1
On sheet 2 g4 = Where is zoo h10 = zoo <<

above
code only counts 1 on Sheet2
On Sheet3 b3 = zoo h4 = zoo

<<
above code only counts 2 on Sheet3

How must I modify countif() above to include zoo when it is within or a

part
of cell, but not exclusively?

Using Edit, Find does OK, it finds 3 on Sheet1; 2 on Sheet2 and 2 on

Sheet3
Confused...
TIA,







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
sum/autosum not calculating correctly websterk12 Excel Worksheet Functions 6 June 24th 09 10:39 PM
Formulas Not Calculating Correctly Daren Excel Discussion (Misc queries) 4 November 27th 07 09:41 PM
Formulas Not Calculating Correctly Daren Excel Worksheet Functions 8 November 27th 07 09:37 PM
why isn't this formula calculating correctly? Dave F Excel Discussion (Misc queries) 13 October 9th 06 01:34 AM
Formulas not calculating correctly MWickline Excel Discussion (Misc queries) 3 June 9th 05 04:10 PM


All times are GMT +1. The time now is 06:11 AM.

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"