Summary sheet of most recent entry from multiple sheets

rachA

New Member
Joined
Feb 22, 2012
Messages
4
Hello,

I'm brand new to this forum, and very stuck with excel, so any help wil be greatly appreciated.

I have a workbook containing 36 sheets with info on individual birds, each with the bird ID as sheet name, and all with same format. Columns from A to G go; Date, Transmitter, Easting, Northing, Weight, Bill, Comment.

I would like to create a summary sheet which pulls the most recent entry from each worksheet, and compiles them with sheet name (which is also the bird ID) in column A, and the most recent data from that sheet in the adjacent cells, so that the summary has one row of most recent data for each bird.

I also need the summary sheet to be able to automatically update and recognise the new entries as I put them in.

I was hoping this code from another forum would do the trick, as it sounds like the person was after exactly the same thing as me...

"Hi
Insert a sheet called Summary and paste the following codes in the macro window ( Alt F11).

Code:

Sub Harley()Dim a As Long, x As Long, y As LongDim b As String For a = 1 To Sheets.Count b = Worksheets(a).Name If b <> "Summary" Then Sheets("Summary").Cells(a + 1, 1) = b x = Worksheets(a).Range("A65536").End(xlUp).Row Sheets("Summary").Cells(1, 1) = "=MATCH(MAX(" & b & "!A1:A" & x & ")," & b & "!A1:A" & x & ", 0)" y = Sheets("Summary").Cells(1, 1) Worksheets(a).Range("A" & y & ":Z" & y).Copy Sheets("Summary").Cells(a + 1, 2).PasteSpecial End If Next aEnd Sub</PRE>
run the macro. it lists sheet names in col A and pastes the most recent data of that sheet from B to AA."

But when I run this in the macro window it comes up with a "run time error 1004"

I have no idea why this is happening, so any help with re-writing this code to fix it, or a brand new code would be fantastic.

Thanks,
Rachael.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
rachA,

Welcome to the MrExcel forum.

What version of Excel are you using?

You will generally get much more help (and faster) in this forum if you can post your small samples directly in the forum:
sensitive data scrubbed/removed/changed
what you have and what you expect to achieve

To attach screenshots, see below in my Signature block:
Post a screen shot with one of these:

If you are not able to give us screenshots, see below in my Signature block:
You can upload your workbook to Box Net
mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
Thanks for those handy hints!

I'm using Excel 2010. Here is a sample of my worksheets...
Excel Workbook
ABCDEFG
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASE
320/12/2010311.5586.9HC
428/04/2011302.187.1TX
52/09/201115B1.987.4TX
AQ0809#1
Excel 2010

And here is what I'd like the summary page to look like;
Excel Workbook
ABCDEFGH
1BirdIDDateTXEastingNorthingWeightBillComment
2AD0910#227/09/201157B1.44naTX
3AQ0809#1
summary
Excel 2010

Any help would be grand.

Thanks,
Rach.
 
Upvote 0
rachA,

Can we have a screenshot of worksheet AD0910#2?

And, maybe one or two more raw data worksheets?
 
Upvote 0
Hi Hiker95,

Yep sure...here are a few more
Excel Workbook
ABCDEFG
1DateTXEastingNorthingWeightBillComment
221/10/201065 YRELEASE
316/12/201001 Y1.07570.6TX
427/09/201157B1.44naTX
AD0910#2
Excel 2010
Excel Workbook
ABCDEFG
1DateEastingNorthingWeightBillComment
221/10/2010RELEASE
34/11/2010
425/11/2010201.425n.a
522/03/2011252.16592.4TX
627/10/2011252.175105.1
AQ0910#1 Pete
Excel 2010
Excel Workbook
ABCDEFG
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASE
325/10/2010
422/11/2010621.3978.5HC
523/03/2011621.481.2
631/08/2011571.787.4TX
726/10/2011571.67589.8
AX0910#1
Excel 2010


As you can see, each sheet has the same setup with column headers, but they have a variable number of data entries, which is why I need a code that will use the most recent date, or entry lowest down the list, to pick up the data for the summary sheet, and automatically update this in the summary sheet if new data is added into the data sheets.

Thanks again for you help with this.

Rach.
 
Upvote 0
rachA,


Sample worksheets:


Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/201065 YRELEASEHIJKLMNOPQRSTUVWXYZAA
316/12/201001 Y1.07570.6TXHIJKLMNOPQRSTUVWXYZAA
4
AD0910#2





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
320/12/2010311.5586.9HCHIJKLMNOPQRSTUVWXYZAA
428/04/2011302.187.1TXHIJKLMNOPQRSTUVWXYZAA
5
AQ0809#1





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
34/11/2010HIJKLMNOPQRSTUVWXYZAA
425/11/2010201.425n.aHIJKLMNOPQRSTUVWXYZAA
522/03/2011252.16592.4TXHIJKLMNOPQRSTUVWXYZAA
6
AQ0910#1 Pete





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
325/10/2010HIJKLMNOPQRSTUVWXYZAA
422/11/2010621.3978.5HCHIJKLMNOPQRSTUVWXYZAA
523/03/2011621.481.2HIJKLMNOPQRSTUVWXYZAA
631/08/2011571.787.4TXHIJKLMNOPQRSTUVWXYZAA
7
AX0910#1





After the macro:


Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1BirdIDDateTXEastingNorthingWeightBillComment
2AD0910#216/12/201001 Y1.07570.6TXHIJKLMNOPQRSTUVWXYZAA
3AQ0809#128/04/2011302.187.1TXHIJKLMNOPQRSTUVWXYZAA
4AQ0910#1 Pete22/03/2011252.16592.4TXHIJKLMNOPQRSTUVWXYZAA
5AX0910#131/08/2011571.787.4TXHIJKLMNOPQRSTUVWXYZAA
6
Summary
 
Upvote 0
rachA,


Then you add one row to each of the Sample worksheets:


Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/201065 YRELEASEHIJKLMNOPQRSTUVWXYZAA
316/12/201001 Y1.07570.6TXHIJKLMNOPQRSTUVWXYZAA
427/09/201157B1.44naTXHIJKLMNOPQRSTUVWXYZAA
5
AD0910#2





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
320/12/2010311.5586.9HCHIJKLMNOPQRSTUVWXYZAA
428/04/2011302.187.1TXHIJKLMNOPQRSTUVWXYZAA
502/09/201115B1.987.4TXHIJKLMNOPQRSTUVWXYZAA
6
AQ0809#1





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
34/11/2010HIJKLMNOPQRSTUVWXYZAA
425/11/2010201.425n.aHIJKLMNOPQRSTUVWXYZAA
522/03/2011252.16592.4TXHIJKLMNOPQRSTUVWXYZAA
627/10/2011252.175105.1HIJKLMNOPQRSTUVWXYZAA
7
AQ0910#1 Pete





Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1DateTXEastingNorthingWeightBillComment
221/10/2010RELEASEHIJKLMNOPQRSTUVWXYZAA
325/10/2010HIJKLMNOPQRSTUVWXYZAA
422/11/2010621.3978.5HCHIJKLMNOPQRSTUVWXYZAA
523/03/2011621.481.2HIJKLMNOPQRSTUVWXYZAA
631/08/2011571.787.4TXHIJKLMNOPQRSTUVWXYZAA
726/10/2011571.67589.8HIJKLMNOPQRSTUVWXYZAA
8
AX0910#1





Before running the macro again, worksheet Summary goes from this:


Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1BirdIDDateTXEastingNorthingWeightBillComment
2AD0910#216/12/201001 Y1.07570.6TXHIJKLMNOPQRSTUVWXYZAA
3AQ0809#128/04/2011302.187.1TXHIJKLMNOPQRSTUVWXYZAA
4AQ0910#1 Pete22/03/2011252.16592.4TXHIJKLMNOPQRSTUVWXYZAA
5AX0910#131/08/2011571.787.4TXHIJKLMNOPQRSTUVWXYZAA
6
Summary





To this:


Excel Workbook
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
1BirdIDDateTXEastingNorthingWeightBillComment
2AD0910#227/09/201157B1.44naTXHIJKLMNOPQRSTUVWXYZAA
3AQ0809#102/09/201115B1.987.4TXHIJKLMNOPQRSTUVWXYZAA
4AQ0910#1 Pete27/10/2011252.175105.1HIJKLMNOPQRSTUVWXYZAA
5AX0910#126/10/2011571.67589.8HIJKLMNOPQRSTUVWXYZAA
6
Summary





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub CreateSummary()
' hiker95, 02/23/2012
' http://www.mrexcel.com/forum/showthread.php?t=615834
Dim wsr As Worksheet, ws As Worksheet
Dim lr As Long, nr As Long
Application.ScreenUpdating = False
If Not Evaluate("ISREF(Summary!A1)") Then Worksheets.Add(Before:=Worksheets(1)).Name = "Summary"
Set wsr = Worksheets("Summary")
wsr.UsedRange.Clear
wsr.Range("A1:H1").Value = Array("BirdID", "Date", "TX", "Easting", "Northing", "Weight", "Bill", "Comment")
For Each ws In ThisWorkbook.Worksheets
  If ws.Name <> "Summary" Then
    lr = ws.Cells(Rows.Count, 1).End(xlUp).Row
    If lr > 1 Then
      nr = wsr.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
      wsr.Cells(nr, 1) = ws.Name
      ws.Cells(lr, 1).Resize(, 27).Copy wsr.Cells(nr, 2)
    End If
  End If
Next ws
wsr.UsedRange.Columns.AutoFit
wsr.Activate
Application.ScreenUpdating = True
End Sub


Then run the CreateSummary macro.
 
Upvote 0
rachA,

I also need the summary sheet to be able to automatically update and recognise the new entries as I put them in.

This is going to be difficult, because, what cell change will trigger the macro for each worksheet?


You will have to run the macro manually each time you want to update the Summary worksheet.
 
Upvote 0
YAY!!! It works perfectly :) Thank you so much. It's no problem to run the macro each time I update the individual sheets.

Thanks again, I really appreciate your help with this.
 
Upvote 0
racha,

Thanks for the feedback.

You are very welcome. Glad I could help.

Come back anytime.
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,604
Members
449,520
Latest member
TBFrieds

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