Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default changing one percentage, but total must be 100

I am trying to create a macro/function that will allow me to change a
percentage in a row, adjust the remaining percentages to still keep my total
100%. I am lost and need help.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default changing one percentage, but total must be 100

If you add 5 to one of them, subtract 5 from one of the others...
Maybe you were looking for something a bit more complicated though.

Tim



"Laurie" wrote in message
...
I am trying to create a macro/function that will allow me to change a
percentage in a row, adjust the remaining percentages to still keep my
total
100%. I am lost and need help.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default changing one percentage, but total must be 100

Where are the other numbers which need to be modified, and how should they be
modified.
--
HTH...

Jim Thomlinson


"Laurie" wrote:

I am trying to create a macro/function that will allow me to change a
percentage in a row, adjust the remaining percentages to still keep my total
100%. I am lost and need help.

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default changing one percentage, but total must be 100

Yes, its more complicated than that. I am setting up an application it has
to be user friendly and must allow for all possibilities. If the user wants
to see how changing one percentage may affect other items in the application,
how can I keep my total 100% if the user choses to change any cell to a
different percentage?

"Tim Williams" wrote:

If you add 5 to one of them, subtract 5 from one of the others...
Maybe you were looking for something a bit more complicated though.

Tim



"Laurie" wrote in message
...
I am trying to create a macro/function that will allow me to change a
percentage in a row, adjust the remaining percentages to still keep my
total
100%. I am lost and need help.

Thanks!




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default changing one percentage, but total must be 100

If there is some dependency between the different items which make up the
100%, then the nature of the dependency would dictate how other items change
when one is adjusted.

In other words, to get a definitive answer you'll need to explain exactly
how you would expect changing one item to "affect other items"...

Tim.


"Laurie" wrote in message
...
Yes, its more complicated than that. I am setting up an application it
has
to be user friendly and must allow for all possibilities. If the user
wants
to see how changing one percentage may affect other items in the
application,
how can I keep my total 100% if the user choses to change any cell to a
different percentage?

"Tim Williams" wrote:

If you add 5 to one of them, subtract 5 from one of the others...
Maybe you were looking for something a bit more complicated though.

Tim



"Laurie" wrote in message
...
I am trying to create a macro/function that will allow me to change a
percentage in a row, adjust the remaining percentages to still keep my
total
100%. I am lost and need help.

Thanks!








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default changing one percentage, but total must be 100


Let us assume that you have four variables in cells A1,A2,A3,A4. As
understand your problem, you want to find out how rest three variable
would be affected if any one of them is changed. In my opinion thi
means that we need to maintain the respective ratio of rest thre
variables same as it was earlier. eg if A1=25, A2=24,A3=25 and A4=2
and we change A1 to say 62.5 A2, A3 and A4 must still maintain thei
earlier proportion (24:25:26) and the new values would be thus A2=12
A3=12.5 and A4=13.

I can suggest procedure

Sub Percent()
TestRow = ActiveCell.Row
TestCol = ActiveCell.Column
NewValue = Cells(TestRow, TestCol).Value
If TestRow = 1 And TestCol = 1 Then
Denominator = [B1] + [C1] + [D1]
[B1] = (100 - NewValue) * [B1] / Denominator
[C1] = (100 - NewValue) * [C1] / Denominator
[D1] = (100 - NewValue) * [D1] / Denominator
End If

If TestRow = 1 And TestCol = 2 Then
Denominator = [A1] + [C1] + [D1]
[A1] = (100 - NewValue) * [A1] / Denominator
[C1] = (100 - NewValue) * [C1] / Denominator
[D1] = (100 - NewValue) * [D1] / Denominator
End If

If TestRow = 1 And TestCol = 3 Then
Denominator = [A1] + [B1] + [D1]
[A1] = (100 - NewValue) * [A1] / Denominator
[B1] = (100 - NewValue) * [B1] / Denominator
[D1] = (100 - NewValue) * [D1] / Denominator
End If

If TestRow = 1 And TestCol = 4 Then
Denominator = [A1] + [B1] + [C1]
[A1] = (100 - NewValue) * [A1] / Denominator
[B1] = (100 - NewValue) * [B1] / Denominator
[C1] = (100 - NewValue) * [C1] / Denominator
End If

End Sub

You will need initialising OnEntry Event procedure eg
Worksheets(1).OnEntry = "Percent" to execute our procedure "Percent
every time you change values in either A1,A2,A3 or A4. It wil
immediately update rest three cells. This could be nuisance. This wil
not allow you to fill up initial values as you want, as other cells ge
affected as soon as you enter any one cell. And since the cells ar
blank to start with , it might give divide by zero error when you ente
the first cell. May be you would want to execute the proc only after yo
click a button or something instead of other cells recalculating as soo
as you enter any one cell.

A V Veerkar

A V Veerka

--
avveerka
-----------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...fo&userid=3033
View this thread: http://www.excelforum.com/showthread.php?threadid=50857

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
add column for percentage o total derwood[_2_] Excel Discussion (Misc queries) 1 December 27th 07 04:53 PM
Percentage total may not exceed 100 The Fool on the Hill Excel Discussion (Misc queries) 5 September 6th 07 03:26 PM
Total Revenue Percentage Willing to learn Excel Discussion (Misc queries) 5 July 19th 07 08:32 PM
Percentage Discount Total mdj101 Excel Discussion (Misc queries) 1 May 18th 06 04:33 PM
a number as a percentage out of a total solskinn Excel Worksheet Functions 3 December 8th 04 06:23 PM


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