totaling indented subsections

S

steev_jd

Hi there,

I have a list that has has a list of entries and sub entries in column
A.

Each sub entry is indented, as below
Column A --------------¬------Column B---¬
-(5 spaces)-ABING..............183427
-(7 Spaces)-ABING..............183423
-(7 Spaces)-PAVA.........................2
-(7 Spaces)-EURM.........................1
-(5 spaces)-AEGIS....................524
-(7 Spaces)-AEGIS....................524
-(5 spaces)-JAGA....................1000
-(7 Spaces)-JAGA.....................900
-(7 Spaces)-LEMA.....................100
-(7 Spaces)-GURM.....................15

I need to total the extra indented sections to see if the match the
less indented entry above them.
i.e. in the example above ABING and AEGIS would be correct, JAGA
wouldn't
as 183426 = 183423+2+1 and 524 = 524
but 1000 does not = 900+100+15.

Does anyone have any suggestions as to how I can speed this process up
rather than calculating every section manually?

Thanks in advance.
Steve
 
M

mrice

Try this user defined function

Function Check(Cell As Range)
If Left(Cell, 7) = " " Then
Check = ""
Else
Counter = 1
Do While Left(Cell.Offset(Counter, 0).Value, 7) = " "
Total = Total + Cell.Offset(Counter, 1)
Counter = Counter + 1
Loop
If Total = Cell.Offset(0, 1) Then
Check = True
Else
Check = False
End If
End If
End Function

Paste this into a VBA module and type =CHECK(A1) into cell C1 and copy
down.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top