PC Review


Reply
Thread Tools Rate Thread

Counta not calculating correctly???

 
 
Kelvin
Guest
Posts: n/a
 
      10th Mar 2008
Count anyone shed some light on this issue.
I am using the statement
n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))

I am trying to get a value for how many of the 3 cells have data in them.
While watching my n count I am seeing it reading 2 when there is clearly
only data in one of the cells.
Any idea why this would be reading incorrectly?

Thanks for any help
--
KWB
 
Reply With Quote
 
 
 
 
Tyro
Guest
Posts: n/a
 
      10th Mar 2008
COUNTA works fine. Are you sure the cells are empty? Perhaps one of them has
a space or other non-visible character in it. Those will be counted by
COUNTA
Try using the LEN function. If the cells are truly empty, LEN will return 0

Tyro

"Kelvin" <(E-Mail Removed)> wrote in message
news:8D315915-BC02-4BF2-B97A-(E-Mail Removed)...
> Count anyone shed some light on this issue.
> I am using the statement
> n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
>
> I am trying to get a value for how many of the 3 cells have data in them.
> While watching my n count I am seeing it reading 2 when there is clearly
> only data in one of the cells.
> Any idea why this would be reading incorrectly?
>
> Thanks for any help
> --
> KWB



 
Reply With Quote
 
Kelvin
Guest
Posts: n/a
 
      10th Mar 2008
Hey Tyro,
That is exactly what I was concerned with.
I will check the LEN function

Thanks
--
KWB


"Tyro" wrote:

> COUNTA works fine. Are you sure the cells are empty? Perhaps one of them has
> a space or other non-visible character in it. Those will be counted by
> COUNTA
> Try using the LEN function. If the cells are truly empty, LEN will return 0
>
> Tyro
>
> "Kelvin" <(E-Mail Removed)> wrote in message
> news:8D315915-BC02-4BF2-B97A-(E-Mail Removed)...
> > Count anyone shed some light on this issue.
> > I am using the statement
> > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
> >
> > I am trying to get a value for how many of the 3 cells have data in them.
> > While watching my n count I am seeing it reading 2 when there is clearly
> > only data in one of the cells.
> > Any idea why this would be reading incorrectly?
> >
> > Thanks for any help
> > --
> > KWB

>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Mar 2008
=counta() will count a cell that contains a formula that evaluate to "" as being
used.

And if you convert that cell that evaluates to "", excel still will count it
using =counta().

Any chance that's what happened?

Kelvin wrote:
>
> Count anyone shed some light on this issue.
> I am using the statement
> n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
>
> I am trying to get a value for how many of the 3 cells have data in them.
> While watching my n count I am seeing it reading 2 when there is clearly
> only data in one of the cells.
> Any idea why this would be reading incorrectly?
>
> Thanks for any help
> --
> KWB


--

Dave Peterson
 
Reply With Quote
 
Henn Sarv
Guest
Posts: n/a
 
      10th Mar 2008
Is that possible that some of those cells contain "" (empty string) in some
reason?

What if You try to manually add some Function on sheet somewhere countA-ing
of those same cells?

Henn

"Kelvin" <(E-Mail Removed)> kirjutas sõnumis
news:8D315915-BC02-4BF2-B97A-(E-Mail Removed)...
> Count anyone shed some light on this issue.
> I am using the statement
> n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
>
> I am trying to get a value for how many of the 3 cells have data in them.
> While watching my n count I am seeing it reading 2 when there is clearly
> only data in one of the cells.
> Any idea why this would be reading incorrectly?
>
> Thanks for any help
> --
> KWB


 
Reply With Quote
 
Tyro
Guest
Posts: n/a
 
      10th Mar 2008
Dave's input is correct. A formula that returns "", the empty string will
have a LEN of 0 but be counted by COUNTA

Tyro

"Kelvin" <(E-Mail Removed)> wrote in message
news:FC5818EB-EBF3-4787-9ED9-(E-Mail Removed)...
> Hey Tyro,
> That is exactly what I was concerned with.
> I will check the LEN function
>
> Thanks
> --
> KWB
>
>
> "Tyro" wrote:
>
>> COUNTA works fine. Are you sure the cells are empty? Perhaps one of them
>> has
>> a space or other non-visible character in it. Those will be counted by
>> COUNTA
>> Try using the LEN function. If the cells are truly empty, LEN will return
>> 0
>>
>> Tyro
>>
>> "Kelvin" <(E-Mail Removed)> wrote in message
>> news:8D315915-BC02-4BF2-B97A-(E-Mail Removed)...
>> > Count anyone shed some light on this issue.
>> > I am using the statement
>> > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
>> >
>> > I am trying to get a value for how many of the 3 cells have data in
>> > them.
>> > While watching my n count I am seeing it reading 2 when there is
>> > clearly
>> > only data in one of the cells.
>> > Any idea why this would be reading incorrectly?
>> >
>> > Thanks for any help
>> > --
>> > KWB

>>
>>
>>



 
Reply With Quote
 
Kelvin
Guest
Posts: n/a
 
      11th Mar 2008
Hey Dave,
Thanks for the input
I wrote a macro to "clear contents" of any empty cells.
Will that truely clear the contents to where CountA will work?

I was also stepping through while watching some variables. len(s) would be
0,0,4 and my counta variable would show 2.
--
KWB


"Dave Peterson" wrote:

> =counta() will count a cell that contains a formula that evaluate to "" as being
> used.
>
> And if you convert that cell that evaluates to "", excel still will count it
> using =counta().
>
> Any chance that's what happened?
>
> Kelvin wrote:
> >
> > Count anyone shed some light on this issue.
> > I am using the statement
> > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
> >
> > I am trying to get a value for how many of the 3 cells have data in them.
> > While watching my n count I am seeing it reading 2 when there is clearly
> > only data in one of the cells.
> > Any idea why this would be reading incorrectly?
> >
> > Thanks for any help
> > --
> > KWB

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Mar 2008
looping through the cells and using .clearcontents should work.

If I've converted formulas to values, I like to select the range:
Edit|Replace
what: (leave blank)
with: $$$$$
replace all

Followed by:
Edit|Replace
what: $$$$$
with: (leave blank)
replace all

If the number of cells to inspect is a lot, then this should work more quickly.

=====
And yep, checking the len(.value) = 0 (or len(trim(.value))) should work ok,
too.

Kelvin wrote:
>
> Hey Dave,
> Thanks for the input
> I wrote a macro to "clear contents" of any empty cells.
> Will that truely clear the contents to where CountA will work?
>
> I was also stepping through while watching some variables. len(s) would be
> 0,0,4 and my counta variable would show 2.
> --
> KWB
>
> "Dave Peterson" wrote:
>
> > =counta() will count a cell that contains a formula that evaluate to "" as being
> > used.
> >
> > And if you convert that cell that evaluates to "", excel still will count it
> > using =counta().
> >
> > Any chance that's what happened?
> >
> > Kelvin wrote:
> > >
> > > Count anyone shed some light on this issue.
> > > I am using the statement
> > > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
> > >
> > > I am trying to get a value for how many of the 3 cells have data in them.
> > > While watching my n count I am seeing it reading 2 when there is clearly
> > > only data in one of the cells.
> > > Any idea why this would be reading incorrectly?
> > >
> > > Thanks for any help
> > > --
> > > KWB

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Kelvin
Guest
Posts: n/a
 
      11th Mar 2008
Excellent information.

Thanks a million for your input.

Also thanks to the others who put some thought into this,
Much appreciated

Kelvin
--
KWB


"Dave Peterson" wrote:

> looping through the cells and using .clearcontents should work.
>
> If I've converted formulas to values, I like to select the range:
> Edit|Replace
> what: (leave blank)
> with: $$$$$
> replace all
>
> Followed by:
> Edit|Replace
> what: $$$$$
> with: (leave blank)
> replace all
>
> If the number of cells to inspect is a lot, then this should work more quickly.
>
> =====
> And yep, checking the len(.value) = 0 (or len(trim(.value))) should work ok,
> too.
>
> Kelvin wrote:
> >
> > Hey Dave,
> > Thanks for the input
> > I wrote a macro to "clear contents" of any empty cells.
> > Will that truely clear the contents to where CountA will work?
> >
> > I was also stepping through while watching some variables. len(s) would be
> > 0,0,4 and my counta variable would show 2.
> > --
> > KWB
> >
> > "Dave Peterson" wrote:
> >
> > > =counta() will count a cell that contains a formula that evaluate to "" as being
> > > used.
> > >
> > > And if you convert that cell that evaluates to "", excel still will count it
> > > using =counta().
> > >
> > > Any chance that's what happened?
> > >
> > > Kelvin wrote:
> > > >
> > > > Count anyone shed some light on this issue.
> > > > I am using the statement
> > > > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
> > > >
> > > > I am trying to get a value for how many of the 3 cells have data in them.
> > > > While watching my n count I am seeing it reading 2 when there is clearly
> > > > only data in one of the cells.
> > > > Any idea why this would be reading incorrectly?
> > > >
> > > > Thanks for any help
> > > > --
> > > > KWB
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Kelvin
Guest
Posts: n/a
 
      11th Mar 2008
Henn,
Seems to work if I loop through and clear the contents of empty cells.
Thanks for the input.
Kelvin
--
KWB


"Henn Sarv" wrote:

> Is that possible that some of those cells contain "" (empty string) in some
> reason?
>
> What if You try to manually add some Function on sheet somewhere countA-ing
> of those same cells?
>
> Henn
>
> "Kelvin" <(E-Mail Removed)> kirjutas sõnumis
> news:8D315915-BC02-4BF2-B97A-(E-Mail Removed)...
> > Count anyone shed some light on this issue.
> > I am using the statement
> > n = WorksheetFunction.CountA(Cells(i, 13), Cells(i, 17), Cells(i, 22))
> >
> > I am trying to get a value for how many of the 3 cells have data in them.
> > While watching my n count I am seeing it reading 2 when there is clearly
> > only data in one of the cells.
> > Any idea why this would be reading incorrectly?
> >
> > Thanks for any help
> > --
> > KWB

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counta not counting correctly!! Meenie Microsoft Excel Misc 2 6th Jan 2010 01:56 PM
COUNTA not adding correctly. S Microsoft Excel Discussion 1 27th Jul 2008 09:30 AM
Calculating totals from COUNTA function =?Utf-8?B?TVc=?= Microsoft Excel New Users 3 13th Mar 2007 04:53 PM
Calculating totals from COUNTA function =?Utf-8?B?TVc=?= Microsoft Excel Misc 3 13th Mar 2007 05:21 AM
sum not calculating correctly =?Utf-8?B?RXhjZWwgaXNzdWU=?= Microsoft Access External Data 2 23rd Sep 2004 04:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:38 PM.