+ Reply to Thread
Results 1 to 10 of 10

Trying to Create a Summary Report

Hybrid View

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Unhappy Trying to Create a Summary Report

    I have a number of worksheets where I have extensive data on Energy Generation. In each worksheet I have added a column (AA) where the data for the day is totalled (I do this manually too and would like to be able to automate it but that is not my biggest issue right now:-)).

    I want to take the total power generation by technology type for each day and place it in a summary sheet. In the attached spreadsheet I have done this manually (summary sheet) but it is very time consuming, especially since I have to do this for many many more months of data.
    Could someone please help me understand what would be an easier way to summarise the data?
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Trying to Create a Summary Report

    Hi Mcrawiva

    This Code is in the attached (if indeed I can add the Attachment) and appears to do as you require, including this

    "In each worksheet I have added a column (AA) where the data for the day is totalled (I do this manually too and would like to be able to automate it"

    Option Explicit
    
    Sub Create_Summary()
        Dim ws As Worksheet, ws1 As Worksheet
        Dim NR As Long, LR As Long, i As Long, j As Long
        Dim myArray As Variant
        Dim c As Range, cel As Range
    
        myArray = Array("NUCLEAR Total", "COAL Total", "GAS Total", "HYDRO Total", "WIND Total", "OTHER Total")
    
        Set ws = Sheets("Summary")
        
        Application.ScreenUpdating = False
        With ws
            NR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row + 1
            .Rows(4).Resize(NR - 1, 1).EntireRow.ClearContents
            NR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row + 1
        End With
        j = 2
        For Each ws1 In ThisWorkbook.Sheets
            If ws1.Name <> "Summary" Then
                With ws1
                    .Range("AA5").Value = "Total Energy Output for 24 hrs"
                    LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious).Row
                    For Each cel In .Range("AA6:AA" & LR)
                        cel.FormulaR1C1 = "=SUM(RC[-24]:RC[-1])"
                    Next cel
                End With
                ws.Range("A" & NR).Value = ws1.Name
                With ws1.Columns(1)
                    For i = LBound(myArray) To UBound(myArray)
                        Set c = .Find(myArray(i), LookIn:=xlValues)
                        ws.Cells(NR, j).Value = c.Offset(1, 26).Value
                        j = j + 1
                    Next i
                End With
                ws.Cells(NR, j - 1).Offset(0, 1).FormulaR1C1 = "=SUM(RC[-6]:RC[-1])"
                j = 2
                NR = NR + 1
            End If
        Next ws1
        Application.ScreenUpdating = True
    End Sub
    I've not figured how to add Quotes nor Code Tags with the "New Look"...hopefully this will make sense.
    Attached Files Attached Files
    Last edited by jaslake; 10-03-2013 at 02:49 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Trying to Create a Summary Report

    This looks GREAT!! The challenge now is when I try to run the macro against a new data-set I get the following error:

    Run time error '91'
    Object variable or with block variable is not seen. I am running the debugger and honestly haven't spent any time on it really but this is where I am at

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Trying to Create a Summary Report

    Hi Mcrawiva

    If the Code works for you in your Sample File and does NOT work in the New Data Set, I'd suggest there's something different in the New Data Set.

    Please post the New Data Set (with Code) and I'll see if I can Debug it for you.

  5. #5
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Smile Re: Trying to Create a Summary Report

    Hi Jaslake, I tried to see if I could see the issue but naw.... So here is the file I tried it on, really appreciate your help.....
    Attached Files Attached Files

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Trying to Create a Summary Report

    Hi Mcrawiva

    The issue is that your Summary Sheet has no Headers; I,ll modify the Code to insert them.

  7. #7
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Trying to Create a Summary Report

    Ah!! I see, when I put the headings in the summary and run the macro then that works too. Brilliant!! Thank you so much, you saved me no end of frustration really appreciate it!!http://www.excelforum.com/images/smilies/smile.gif

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Trying to Create a Summary Report

    Hi Mcrawiva

    This Code has been modified to add Headers to Summary if they don't exist.

    Mods and Admins...please excuse the absence of Code Tags...my current Interface lacks that Option

    Option Explicit
    
    Sub Create_Summary()
        Dim ws As Worksheet, ws1 As Worksheet
        Dim NR As Long, LR As Long, i As Long, j As Long
        Dim myArray As Variant, Headers As Variant
        Dim c As Range, cel As Range
    
        myArray = Array("NUCLEAR Total", "COAL Total", "GAS Total", "HYDRO Total", "WIND Total", "OTHER Total")
        Headers = Array("Date", "Nuclear", "Coal", "Gas", "Hydro", "Wind", "Other", "Total Energy Output for 24 hrs")
    
        Set ws = Sheets("Summary")
    
        Application.ScreenUpdating = False
        With ws
            .Cells.Clear
            .Range("A3").Resize(1, UBound(Headers) + 1) = Headers
            NR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row + 1
        End With
        j = 2
        For Each ws1 In ThisWorkbook.Sheets
            If ws1.Name <> "Summary" And Not ws1.Name = "Sheet1" Then
                With ws1
    '                .Range("AA5").Value = "Total Energy Output for 24 hrs"
                    LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious).Row
                    .Range("H4").FormulaR1C1 = "=SUM(RC[-24]:RC[-1])"
                    .Range("H4").AutoFill Destination:=.Range("H4:H" & LR), Type:=xlFillDefault
    
                    '                For Each cel In .Range("AA6:AA" & LR)
                    '                    cel.FormulaR1C1 = "=SUM(RC[-24]:RC[-1])"
                    '                Next cel
                End With
                ws.Range("A" & NR).Value = ws1.Name
                With ws1.Columns(1)
                    For i = LBound(myArray) To UBound(myArray)
                        Set c = .Find(myArray(i), LookIn:=xlValues)
                        ws.Cells(NR, j).Value = c.Offset(1, 26).Value
                        j = j + 1
                    Next i
                End With
                ws.Cells(NR, j - 1).Offset(0, 1).FormulaR1C1 = "=SUM(RC[-6]:RC[-1])"
                j = 2
                NR = NR + 1
            End If
        Next ws1
        Application.ScreenUpdating = True
    End Sub
    Last edited by jaslake; 10-03-2013 at 01:44 PM. Reason: added Code Tags

  9. #9
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Trying to Create a Summary Report

    Ah!! I see, when I put the headings in the summary and run the macro then that works too. Brilliant!! Thank you so much, you saved me no end of frustration really appreciate it!!

  10. #10
    Registered User
    Join Date
    10-02-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Trying to Create a Summary Report

    mmmm, not quite got it..my brain is numb, will need to look at it tomorrow...Many Thanks

+ 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. Is it possible to create a summary report?
    By Huddle in forum Excel General
    Replies: 5
    Last Post: 08-20-2010, 03:37 PM
  2. Report - create summary of transactions
    By mperedithe in forum Excel General
    Replies: 1
    Last Post: 10-02-2007, 06:38 PM
  3. not able to create subtotal summary report
    By Ron Desrosiers in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-21-2006, 07:40 PM
  4. How to create summary of expense report?
    By KAE1994 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  5. How to create summary of expense report?
    By KAE1994 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-08-2005, 01:05 PM

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