+ Reply to Thread
Results 1 to 2 of 2

totaling indented subsections

  1. #1
    Registered User
    Join Date
    04-03-2006
    Posts
    24

    totaling indented subsections

    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

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    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.
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1