Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Formula needed with a changing denominator for each grouping

I have numerous groupings of the following information. I'm trying to create
a formula or macro that will calculate the allocation (part/whole) by
automatically updating the denominator based on where the next blank line is,
signifying the next group, and subtracting one (to where the "over all" line
is). The next group would automatically use the new denominator. I don't
want to have to manually change the equation for each group.

EQUITY $310,481 98%
FIXED INCOME $- 0%
CASH EQUIVALENTS $5,644 2%
CASH $- 0%
OVER ALL $316,125 100%

EQUITY $1,153,192
FIXED INCOME $871,634
CASH EQUIVALENTS $22,972
CASH $3,598
OVER ALL $2,051,396

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Formula needed with a changing denominator for each grouping

Sub AddPercentages()
Dim rng as range, ar as Range
set rng = columns(2).specialCells(xlConstants,xlNumbers)
for each ar in rng.areas
ar.offset(0,1).formula= "=" & ar(1).Address(0,1) & _
"/" & ar(ar.count).address(1,1)
ar.offset(0,1).Numberformat = "0%"
Next
End Sub



"MissyLovesExcel" wrote in
message ...
I have numerous groupings of the following information. I'm trying to

create
a formula or macro that will calculate the allocation (part/whole) by
automatically updating the denominator based on where the next blank line

is,
signifying the next group, and subtracting one (to where the "over all"

line
is). The next group would automatically use the new denominator. I don't
want to have to manually change the equation for each group.

EQUITY $310,481 98%
FIXED INCOME $- 0%
CASH EQUIVALENTS $5,644 2%
CASH $- 0%
OVER ALL $316,125 100%

EQUITY $1,153,192
FIXED INCOME $871,634
CASH EQUIVALENTS $22,972
CASH $3,598
OVER ALL $2,051,396



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Formula needed with a changing denominator for each grouping

Okay, I get a VBA error "400" is all it says when I try to run it. Any
thoughts?

"Tom Ogilvy" wrote:

Sub AddPercentages()
Dim rng as range, ar as Range
set rng = columns(2).specialCells(xlConstants,xlNumbers)
for each ar in rng.areas
ar.offset(0,1).formula= "=" & ar(1).Address(0,1) & _
"/" & ar(ar.count).address(1,1)
ar.offset(0,1).Numberformat = "0%"
Next
End Sub



"MissyLovesExcel" wrote in
message ...
I have numerous groupings of the following information. I'm trying to

create
a formula or macro that will calculate the allocation (part/whole) by
automatically updating the denominator based on where the next blank line

is,
signifying the next group, and subtracting one (to where the "over all"

line
is). The next group would automatically use the new denominator. I don't
want to have to manually change the equation for each group.

EQUITY $310,481 98%
FIXED INCOME $- 0%
CASH EQUIVALENTS $5,644 2%
CASH $- 0%
OVER ALL $316,125 100%

EQUITY $1,153,192
FIXED INCOME $871,634
CASH EQUIVALENTS $22,972
CASH $3,598
OVER ALL $2,051,396




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Formula needed with a changing denominator for each grouping

It ran fine for me.

Try closing excel and re-opening. I have had that error box pop up before
(on other occasions). It seems to be more an internal excel problem and
not related to anything in the code.

--
Regards,
Tom Ogilvy


"MissyLovesExcel" wrote in
message ...
Okay, I get a VBA error "400" is all it says when I try to run it. Any
thoughts?

"Tom Ogilvy" wrote:

Sub AddPercentages()
Dim rng as range, ar as Range
set rng = columns(2).specialCells(xlConstants,xlNumbers)
for each ar in rng.areas
ar.offset(0,1).formula= "=" & ar(1).Address(0,1) & _
"/" & ar(ar.count).address(1,1)
ar.offset(0,1).Numberformat = "0%"
Next
End Sub



"MissyLovesExcel" wrote in
message ...
I have numerous groupings of the following information. I'm trying to

create
a formula or macro that will calculate the allocation (part/whole) by
automatically updating the denominator based on where the next blank

line
is,
signifying the next group, and subtracting one (to where the "over

all"
line
is). The next group would automatically use the new denominator. I

don't
want to have to manually change the equation for each group.

EQUITY $310,481 98%
FIXED INCOME $- 0%
CASH EQUIVALENTS $5,644 2%
CASH $- 0%
OVER ALL $316,125 100%

EQUITY $1,153,192
FIXED INCOME $871,634
CASH EQUIVALENTS $22,972
CASH $3,598
OVER ALL $2,051,396






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
How to protect sheet allowing grouping and ungrouping but alsoallowing changing colour of specific cells Anurag Kothari Excel Discussion (Misc queries) 2 October 13th 09 02:29 PM
Is there a formula to calculate the least common denominator? Gizmo Excel Worksheet Functions 16 May 16th 09 10:39 PM
VB Script Code needed for Grouping Rows Abhi_Rise Excel Discussion (Misc queries) 0 February 19th 08 02:01 PM
changing year grouping in pivot table Becksicle Excel Discussion (Misc queries) 4 January 21st 08 05:50 PM
How to cause the value in the denominator change with changing row nander Excel Discussion (Misc queries) 6 March 22nd 06 01:11 AM


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