Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob
 
Posts: n/a
Default Database Functions - Strange results

Cell A1 = "Red"
Cell A2 = "Green, Red"

When I use DCOUNTA to determine the number of "Red" occurrences, the result
is 1 (rather than 2). Can someone explain why this happens (and a solution
for obtaining the correct count)? Thanks for the help.
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Otto Moehrbach
 
Posts: n/a
Default Database Functions - Strange results

Bob
That happens because the DCOUNTA function counts the number of cells
that contain "Red" as the whole entry in the cell. That's 1.
I don't know if there is a formula way to do what you want, but you can
do it with the following macro. I wrote the macro assuming that your data
is in Column A starting with A1. Also, I assumed you wanted to count all
instances of "Red" regardless of case. Note that all instances of "red"
will be counted even if the "red" is not a separate word. For instance,
"redress" is one instance of "red". Post back if this does not do what you
want. HTH Otto
Sub CountRed()
Dim RngColA As Range
Dim i As Range
Dim c As Long
c = 0
Set RngColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
For Each i In RngColA
If InStr(UCase(i.Value), "RED") 0 Then c = c + 1
Next i
MsgBox c
End Sub
"Bob" wrote in message
...
Cell A1 = "Red"
Cell A2 = "Green, Red"

When I use DCOUNTA to determine the number of "Red" occurrences, the
result
is 1 (rather than 2). Can someone explain why this happens (and a
solution
for obtaining the correct count)? Thanks for the help.



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
vlookup on pivot table results = #N/A Louis Excel Worksheet Functions 5 May 13th 23 07:43 PM
excel database statistical functions (DSUM etc..) CraigS Excel Discussion (Misc queries) 1 March 28th 06 06:19 AM
functions are not displaying the results [email protected] Excel Worksheet Functions 1 February 16th 06 01:27 PM
Graphing Database Growth Rate DavidM Charts and Charting in Excel 1 February 2nd 05 12:01 AM
PivotTable canned functions doco Excel Discussion (Misc queries) 0 January 14th 05 03:52 PM


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