Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 100% quandry

Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need to
show how many are in each category as a number and as a percentage. Now the
number aspect of display is easy, but I'm coming unstuck with the percetange
aspect.

In essence as I do my % calc for each category sometimes certain values are
1% less or more than they should be and as you add up the displayed figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30 people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 100% quandry

Hi, "Mojo"

Don't use ROUND...

--
Bien amicordi@lement,

Patrick BAST@RD
patrick.*******chezdbmail.com

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need
to
show how many are in each category as a number and as a percentage. Now
the
number aspect of display is easy, but I'm coming unstuck with the
percetange
aspect.

In essence as I do my % calc for each category sometimes certain values
are
1% less or more than they should be and as you add up the displayed
figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30
people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default 100% quandry

Hi Mojo,

First use percentage format in all the cells you want to display as
percentages, including the cell that will contain the 100% result. Then in
all the peoples percentage cells use the following formula:

=C1*0.01/(SUM($C1:$H16)*0.01)

In the result cell simply use a sum formula of all the percentage people

Hope this helps.

--
A. Ch. Eirinberg


"Mojo" wrote:

Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need to
show how many are in each category as a number and as a percentage. Now the
number aspect of display is easy, but I'm coming unstuck with the percetange
aspect.

In essence as I do my % calc for each category sometimes certain values are
1% less or more than they should be and as you add up the displayed figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30 people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default 100% quandry

Or to use your named ranges use as follows:

intPeopleCount*0.01/(intTotalPeopleCount)*0.01)
--
A. Ch. Eirinberg


"Howard31" wrote:

Hi Mojo,

First use percentage format in all the cells you want to display as
percentages, including the cell that will contain the 100% result. Then in
all the peoples percentage cells use the following formula:

=C1*0.01/(SUM($C1:$H16)*0.01)

In the result cell simply use a sum formula of all the percentage people

Hope this helps.

--
A. Ch. Eirinberg


"Mojo" wrote:

Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need to
show how many are in each category as a number and as a percentage. Now the
number aspect of display is easy, but I'm coming unstuck with the percetange
aspect.

In essence as I do my % calc for each category sometimes certain values are
1% less or more than they should be and as you add up the displayed figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30 people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default 100% quandry

"Mojo" wrote:
This might be an age old problem
[....]
sometimes certain values are 1% less or more than
they should be and as you add up the displayed
figures the total might come out at 99% or 101%


This is a very common real-world effect of rounding. There are no good ways
to avoid it completely, although there are schemes for ameliorating it.
Professional accounting reports usually have a footnote acknowledging the
fact that rounded values might not add up to the whole.


My code for each percentage value is simply:
Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"


It is unclear if this is VBA code and you are storing this result into
Range.Value, or if this is a formula. If the latter, it would be better to
store a number and use the Percentage format; that is, simply
Round(intPeopleCount/intTotalPeopleCount,2).


I really want to make this work, but it seems fraught with issues!!
Any ideas?


Assuming you store numbers formatted as Percentage, one approach is to put
the following formula into each cell (assuming A2:A9 is intPeopleCount, A10
is intTotalPeopleCount and these formulas are in B2:B9):

=max(0,round(sum($A$2:A2)/$A$10 - sum($B$1:B1),2))

This has the effect of distributing the round-off "error". Note that the
intent is for the relative references A2 and B1 to change in each formula.
And this assumes that B1 is empty, text or zero.

That works with your example, and many others. However, I don't believe it
is a panacea. There may be examples where it still does not work, or it
produces nonsensical results (e.g. non-zero percentage for a category of
zero).

PS: I threw in MAX(0,...) as an insurance policy. I am not sure it is
needed.


----- original message -----

"Mojo" wrote in message
...
Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need
to
show how many are in each category as a number and as a percentage. Now
the
number aspect of display is easy, but I'm coming unstuck with the
percetange
aspect.

In essence as I do my % calc for each category sometimes certain values
are
1% less or more than they should be and as you add up the displayed
figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30
people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default 100% quandry

because you're actually rounding values, you're altering them ...so it's
quite likely that your numbers won't sum to 100%

eg 34. 34 + 34.34 + 31.32= 100
BUT 34.3 + 34.3 +31.3 = 99.9

I'd recommend that you leave your formula unadjusted,
=(intPeopleCount / intTotalPeopleCount) * 100

and that you FORMAT the cells to show integegers.

"Mojo" wrote in message
...
Hi All

This might be an age old problem, but I just wanted to see if I wasn't
missing something obvious in my code.

Basically I have say 31 people (this figure can range from 10 to 100) who
are put into 8 categories. Once they have been categorised I simply need
to
show how many are in each category as a number and as a percentage. Now
the
number aspect of display is easy, but I'm coming unstuck with the
percetange
aspect.

In essence as I do my % calc for each category sometimes certain values
are
1% less or more than they should be and as you add up the displayed
figures
the total might come out at 99% or 101%, which looks daft.

An example of a display problem is as follows

1 0 2 9 11 5 0 2 = 30
people
3% 0% 7% 30% 37% 17% 0% 7% = 101% !!!!

My code for each percentage value is simply:

Round((intPeopleCount / intTotalPeopleCount) * 100, 0) & "%"

I really want to make this work, but it seems fraught with issues!!

Any ideas?

Thanks



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
100% quandry Mojo Excel Discussion (Misc queries) 6 June 1st 09 01:56 PM
Another hyperlink quandry: pvdalen[_2_] Excel Programming 5 November 29th 07 06:01 PM
COUNTIF quandry JohnLute Excel Worksheet Functions 6 August 20th 07 06:29 PM
macro quandry.....?? Daesthai Excel Discussion (Misc queries) 2 June 29th 05 07:29 PM
SQL Query Quandry Laphan[_2_] Excel Programming 7 April 20th 04 11:33 AM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"