+ Reply to Thread
Results 1 to 12 of 12

Macro to update and populate a summary table with data from multiple and new sheets added.

  1. #1
    Registered User
    Join Date
    01-12-2014
    Location
    England
    MS-Off Ver
    Excel 2008
    Posts
    1

    Macro to update and populate a summary table with data from multiple and new sheets added.

    Hi there!

    My conundrum:

    There are multiple sheets in a workbook that are all duplicates of one another in terms of layout and design but with varying data between them.

    Because these data sheets are the same layout, the specific cell that is required to be represented in the summary sheet's table is always in the same location across all tabs.

    I want the macro to be flexible in that it can cope if further data sheets are added, updating the summary table (especially the TOTAL row) and inserting new rows for each of the new added data sheets.

    If anyone could offer any guidance it would be greatly appreciated.

    Attached is an excel workbook that attempts to resemble my problem and if anyone can provide the macro needed to get this working then I can attempt to transfer that over to my actual spreadsheet I am working on.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi Imogen,

    Here's a start:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Press ALT + F11 to open the Visual Basic Editor.

    Open a macro-enabled Workbook or save your Workbook As Macro-Enabled

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    And, you should be ready to go

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    Last edited by xladept; 01-12-2014 at 07:09 PM. Reason: Per JMAC observation
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Another option

    I was tempting to use dictionary scripting, but I suspect you have a MAC.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi XLAdept,

    that is one neat solution from which I have discovered a couple of new techniques that would never have occurred to me (enthusiastic amateur with no training in VBA or Excel other than some experience). My solution would have taken many more lines of code for sure (I resolved a very similiar issue for another thread in the last couple of days)

    However, it seems to me while stepping through the code that the " Range("A" & F.Row) = wu.Name" statement should probably be
    "Range("A" & F.Row - 1) = wu.Name"

    In my testing it looks like you were adding in the new sheet on top of the total line and not in the blank line you had just created

    Happy to hear why I am wrong as I am still learning

    Jmac1947

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    sorry, forgot to subscribe to thread

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi jmac,

    However, it seems to me while stepping through the code that the " Range("A" & F.Row) = wu.Name" statement should probably be
    "Range("A" & F.Row - 1) = wu.Name"
    I didn't test this but I expected that the F.Row would be the new blank one - didn't that work out?

    You're right I've edited that post - Thanks
    Last edited by xladept; 01-12-2014 at 07:06 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi xladept,

    based on some solid testing (like one executoin to see the error and another to replicate it, but not a third to test my assumption) you are overwriting the total line.

    I just realised my suggestion will not work either so i am a bit stumped as well

  8. #8
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    I tried a bit more playing around (remember I am not in my comfort zone here) and ended up with this:

    Please Login or Register  to view this content.
    This is happily inserting the line and updating values correctly but seems to be having an issue with the sheet names in col A

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi jmac,

    I think I fixed it - did you try the corrected post #2??

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    @AB33 - I'd love to see how you would use the dictionary scripting with this (I'm new to dictionary and enthused about it ever since a post by snb)

  11. #11
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi xladept,

    Yep, just updated the macro on my machine with your latest code from post #2 and it works a treat in my testing

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to update and populate a summary table with data from multiple and new sheets ad

    Hi xladept,
    Will send you a solution at some time today(Too busy right now)

+ 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. Replies: 4
    Last Post: 05-02-2013, 04:39 PM
  2. [SOLVED] Writing a macro to collect data (selective) from multiple sheets to a summary sheet
    By hstuard in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-21-2013, 02:59 PM
  3. Replies: 1
    Last Post: 03-02-2010, 10:40 PM
  4. Replies: 2
    Last Post: 11-03-2009, 03:30 PM
  5. data entered on multiple sheets also added to summary sheet
    By Nadia in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2005, 04:05 AM

Tags for this Thread

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