+ Reply to Thread
Results 1 to 18 of 18

Populate amounts for separated range based on matching headers across sheets for partial

  1. #1
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Populate amounts for separated range based on matching headers across sheets for partial

    Hello
    in summary sheet there is multiple ranges contains headers are red font color should match these partial items with others sheets are existed in column B and should sum amount the for the whole column whether in the same sheet or across sheet for DEBIT or CREDIT columns after fill ranges then should subrtact separated range from adjacent separated range in column I:L
    for instance :
    NET PUR PURCHASE
    will subtract 178800-6540=172260 as in I3
    so should take next two separated ranges and subtract from each other .
    notice: there partial item is repeated for more than one sheet ,then should merge across sheets.
    the result in last sheet but suppose in summary sheet.
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Populate amounts for separated range based on matching headers across sheets for part

    Hi abdo,

    Try below code ...
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    thanks,
    does the code deal with new items when add in any sheet and add the new item in header for new separated range?
    I no know what's my bad !
    I did with new item in column F where there is separated range as the others , but doesn't bring any thing !
    Last edited by abdo M; 06-30-2023 at 02:39 AM.

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Populate amounts for separated range based on matching headers across sheets for part

    The code should pick it up .. The loop is going sheet "summary" columns C:F and text in "Red" and for the other range (2nd part of the code) should get the NET in row 2 starting from H2

    If that doesn't work, please post another sample workbook to investigate the issue.

  5. #5
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    ok see the rows 19,20 in first sheet, and F22 in summary sheet
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this ...


    So weird to overcomplicate with such bad Summary worksheet layout and
    to not use directly worksheet formulas rather than VBA …

    Anyway according to your attachment an Excel basics VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
        
    Dim R&, C%, T(10), S&
            
    2
        With Worksheets
    ("summary")
        While 
    Not IsEmpty(.Cells(R3))
        For 
    3 To 6 Step 3
            T
    (10) = 0
        
    For 1 To .Index 1
            T
    (10) = T(10) + Worksheets(S).Evaluate(Replace("SUMIF(B:B,""#*"",C:C)-SUMIF(B:B,""#*"",D:D)""#", .Cells(RC)))
        
    Next
            T
    (00) = Array("DEBIT""CREDIT")(-(T(10) <= 0))
            
    T(10) = Abs(T(10))
           .
    Cells(1C).Resize(2) = T
        Next
            R 
    6
        Wend
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Populate amounts for separated range based on matching headers across sheets for part


    Quote Originally Posted by abdo M View Post
    I no know what's my bad !
    Your bad is your summary cell F21 equal to 'DEBIT' as first sheet rows #19 & 20 values are in 'CREDIT' column …

  8. #8
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    @nankw83
    now after Marc make attention for my bad your code works perfectly .
    thank you so much .

  9. #9
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    Your bad is your summary cell F21 equal to 'DEBIT' as first sheet rows #19 & 20 values are in 'CREDIT' column …
    thanks Marc ,
    by the way you forgot showing in range H:last column (last column means add new item based on separated range) .

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Populate amounts for separated range based on matching headers across sheets for part


    Thanks for the rep' !

    I not forgot as it's useless just using formulas and
    my demonstration shows how to get rid of summary existing DEBIT / CREDIT …

  11. #11
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    I not forgot as it's useless just using formulas and
    if the formula depends on header (H2:.....) then it's useless because I will add new header for new formula for every time add new header.

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Populate amounts for separated range based on matching headers across sheets for part


    No header as always just with cell reference like for your useless TOTAL cells …

  13. #13
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    you're talking about sumif formula? , if it's so forgive me this is the only way I know it.

  14. #14
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Try this ...


    No as I were stating about H3:L3 …
    As any Excel user does not need any VBA code but just formulas for the worksheet summary !

    But for lazy just with an UDF like :

    PHP Code: 
    Function GetSum@(ByVal K$)
         For 
    S& = 1 To Application.ThisCell.Parent.Index 1
             GetSum 
    GetSum Worksheets(S).Evaluate(Replace("SUMIF(B:B,""#*"",D:D)-SUMIF(B:B,""#*"",C:C)""#"K))
         
    Next
    End 
    Function 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    just question I have to change structure as you did it ?
    it's not possible to do that my way ?

  16. #16
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Populate amounts for separated range based on matching headers across sheets for part


    No, just an example according to Excel rules as when using formulas it is not necessary to launch manually any VBA procedure
    when any source data changes like with your over complicated way …

  17. #17
    Forum Contributor
    Join Date
    05-25-2022
    Location
    Asia
    MS-Off Ver
    2016
    Posts
    247

    Re: Populate amounts for separated range based on matching headers across sheets for part

    Hi Marc ,
    I'm still interesting for your code , but I think you don't understand totally my request in H:L
    my way should subtract directly without show target columns for subtraction as your way and if I use function , then I have to select individual range manually . so why in this case vba is useless?
    my way in subtraction should be between C,F for each two consecutive range

  18. #18
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Populate amounts for separated range based on matching headers across sheets for part


    Ok, go with post #2 …

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] populate amounts in column based on the same column between two sheets
    By abdo M in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-11-2023, 04:06 PM
  2. [SOLVED] fill empty lists for separated range based on matching header across sheets
    By Mussala in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2022, 08:47 AM
  3. [SOLVED] clear cells for each separated ranged based on headers
    By Ali-M in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-21-2022, 09:21 AM
  4. [SOLVED] split data based on three columns to multiple sheets and rename sheets based on headers
    By KalilMe in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2021, 08:35 AM
  5. [SOLVED] Populate Listbox From a range of cells AND comma separated values
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2015, 11:13 AM
  6. [SOLVED] VBA to Populate Sheets by Matching column headers
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 56
    Last Post: 11-06-2013, 08:41 AM
  7. Inventory Spreadsheet - enter amounts based on matching ingredient
    By direwolf91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2012, 11:32 AM

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