Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum in hierarchy


I'd came close with below loops. But it gave me #VALUE or #NAME error.
Here is what I did, I go to the Lowlevel (eg 4) and record it row's
number - the column is still unchange. It's loops until found a level
that less one than current level. Then the record will restart.

Problem here is, I record column and row's number as string. It's seems
to cause the error. It became like A119, A118, A117 etc. In the final
I'd like to make it became "=SUM(A119,A118,A117)" but the actual
formula wrote in the cell was =SUM('A119','A118','A117') and it's not
summing anything. Any idea how can I make the formula working?

Here is my code:

strSum = ""
For lngLevel = LevelMax To 1 Step -1
For lngRow = lngLastRow To 3 Step -1
Select Case .Cells(lngRow, colLevel).Value
Case lngLevel
strSum = strSum & strColTotal & lngRow & ","
Case lngLevel - 1
strSum = Mid(strSum, 1, Len(strSum) - 1) & ")"
..Cells(lngRow, colTotal).FormulaR1C1 = "=SUM(" &
strSum & ")"
strSum = ""
End Select
Debug.Print strSum
Next
Next

Any ideas are really appreciated.


--
hideki
------------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...o&userid=18903
View this thread: http://www.excelforum.com/showthread...hreadid=515368

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 do I set up hierarchy in Excel? LailaH Excel Discussion (Misc queries) 2 November 20th 08 05:49 PM
Hierarchy table Derrick Excel Discussion (Misc queries) 1 October 31st 08 01:53 AM
Supervisor Hierarchy Steve C Excel Discussion (Misc queries) 0 July 17th 08 03:34 AM
Hierarchy in excel jamshaggy New Users to Excel 1 July 23rd 06 06:49 PM
SUMPRODUCT - HIERARCHY Matt Brown via OfficeKB.com Excel Worksheet Functions 5 November 6th 04 03:54 AM


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