VBA create results sheet

tsitsicat1

New Member
Joined
Jun 27, 2018
Messages
10
Good morning to all!
I have a weekly report from our erp system that shows aging analysis of our sales that contains 16 sheets with rows that aren't the same ever time.
I would like the final row of every sheet to be copy in another sheet in order to create a table that shows the results of all the sheets in one.
Can anyone help me with this?
I spend over 2 hours per week in order to manage this.
Pleaseeee...
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Code:
Sub CopyAll()
Dim sht As Worksheet, shtTarg As Worksheet
Dim r As Long

Sheets(1).Activate
Sheets.Add
Set shtTarg = ActiveSheet
shtTarg.Name = "Total"

Sheets(2).Activate
Rows("1:1").Copy
shtTarg.Activate
Range("A1").Select
ActiveSheet.Paste

For Each sht In Sheets
   If sht.Name <> "Total" Then
      sht.Activate
      Range("A1").Select
      GotoBtm
      r = ActiveCell.Row
      Rows(r & ":" & r).Copy
      shtTarg.Activate
      GotoBtm
      ActiveSheet.Paste
      NextRow
   End If
Next
Set sht = Nothing
Set shtTarg = Nothing
End Sub

Private Sub GotoBtm()
Select Case True
   Case ActiveCell.Value = ""
   Case ActiveCell.Offset(1, 0).Value = ""
       ActiveCell.Offset(1, 0).Select
   Case Else
       Selection.End(xlDown).Select
End Select
End Sub

Private Sub NextRow()
ActiveCell.Offset(1, 0).Select
End Sub
 
Last edited:
Upvote 0
This is just another approach ...

Code:
Sub ConsolidateTotals()
Dim ws As Worksheet, Rg As Range, lRow As Long, lCol As Long, Arr() As String, Cnt As Long
ReDim Arr(1 To Sheets.Count)
Set ws = Sheets.add(after:=Sheets(Sheets.Count))
ws.Name = "Totals Sheet"
For Each ws In Worksheets
    If ws.Name <> "Totals Sheet" Then
        lRow = ws.Range("A" & Rows.Count).End(xlUp).Row
        lCol = ws.Cells(lRow, Columns.Count).End(xlToLeft).Column
        Set Rg = ws.Range(ws.Cells(lRow, 1), ws.Cells(lRow, lCol))
        Cnt = Cnt + 1
        Arr(Cnt) = ws.Name
        With Sheets("Totals Sheet")
            lRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
            .Range("A" & lRow).Resize(, lCol) = Rg.Value
        End With
    End If
Next
With Sheets("Totals Sheet")
    .Columns(1).EntireColumn.Insert
    .Range("A2").Resize(UBound(Arr)).Value = Application.Transpose(Arr)
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top