Consulting

Results 1 to 6 of 6

Thread: SUM multiple COLUMNS DATA with common HEADER NAME

  1. #1
    VBAX Newbie
    Joined
    Feb 2021
    Posts
    4
    Location

    SUM multiple COLUMNS DATA with common HEADER NAME

    Dear VBA Gurus,

    sir, I'm new to macros in excel. i dont have any knowledge of programming, I work as a Jr.Accountant , i have a situation to prepare the SUMMARISED DATA based on the sheets in excel file. ill list details of the sheet content in POINTS BELOW.

    1.I have a excel file with 12 Sheets (each month of year , from Jan to Dec)
    2.I have 195 Columns (Maximum) per sheet (Jan 195 Columns, Feb - 177 Columns & so on...)
    3.My data for calculation starts from Column 10(J) in each sheet
    4.I have 2 Headers, 1st Header is DAY of the month (01,02,03...28/31)
    5.Each Day has SUBHEADER under which there are 6 Columns with SUBHEADING (G,D,M,F,C,O), for each day it will repeat
    6. I want to SUM all the columns with G as Subheader from J to last column and post its SUM in Column 4(D) ,
    D as SUBHEADER from J to last column and post its SUM in Column 5(E),
    M as SUBHEADER from J to last column and post its SUM in Column 6(F),
    F as SUBHEADER from J to last column and post its SUM in Column 7(G),
    C as SUBHEADER from J to last column and post its SUM in Column 58(H),
    O as SUBHEADER to from J to last column and post its SUM in Column 9(I)
    7.It must add all the existing rows in the sheet
    8.It must repeat for all the Sheets (12 Sheets)

    for ex, in Jan month there are 31 times G Column and the rest of all columns come 31 times.

    I'm introduced to MACROS in excel for the first time.
    hope you understand my question (in points),
    Kindly I request you to provide me with the VBA code.

    i have attached the screenshot of the excel sheet.
    Thanks
    Qavi
    Attached Images Attached Images

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    1. I've got ideas but I need to test them so could you supply a workbook with this sort of data in?
    2. What version of Excel are you using?
    3. Do you have the FILTER function available in that version?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    Feb 2021
    Posts
    4
    Location

    Excel File attached as per your SUGEGSTION

    Dear Sir,

    Many Many Thanks for the reply, i appreciate lots to you, for your nice gesture.

    1.Im attaching the excel file with that data
    2.Excel version is 2019
    3.FILTER Function is not available in 2019 it seems i searched in google and writing it.

    Thanks in advance
    Qavi
    Attached Files Attached Files

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    In your sheets, ensure that the range D2:I2 is the same as in your picture with msg#1 above.
    Then put this macro into a standard code-module:
    Sub blah()
    For Each Sht In ThisWorkbook.Worksheets
      x = Application.Match(Left(Sht.Name, 3), Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Now", "Dec"), 0)
      If Not IsError(x) Then
        Sht.Range("D3:I81").FormulaR1C1 = "=SUMIF(R2C10:R2C195,R2C,RC10:RC195)+SUMIF(R2C10:R2C195,R2C,R[1]C10:R[1]C195)"
        'sht.Range("D3:I81").Value = sht.Range("D3:I81").Value 'optional line to convert the formulae to plain values.
      End If
    Next Sht
    End Sub
    Will only affect sheets whose name's first 3 letters are the first 3 letters of English months.
    See comment in the code too.
    See attached. Button at cell N4 of Jan-21 sheet.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Newbie
    Joined
    Feb 2021
    Posts
    4
    Location
    Dear Sir,

    I'l check and update you,
    Many Thanks in Advance

    Qavi

  6. #6
    VBAX Newbie
    Joined
    Feb 2021
    Posts
    4
    Location
    Dear Sir,

    Perfectly Working..... 100%.

    Thanks a Lot.
    Appetite your kind help.


    Qavi

Tags for this Thread

Posting Permissions

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