+ Reply to Thread
Results 1 to 3 of 3

Consolidated workbook to VBA worksheet table merge followed by refresh data

  1. #1
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Unhappy Consolidated workbook to VBA worksheet table merge followed by refresh data

    Hello there,

    I am having quite the predicament with my VBA solution for consolidating worksheets.

    The situation: Due to the work processes here, each individual (6) would like to have a separate worksheet to enter in information for a defect on a form. Using this tally sheet they save the information in the sheet and close it at the end of their process. This workbook (6 of them in total) is on a SharePoint 2013 site under a library (similar to a network drive, kinda). I have the 6 workbooks consolidated into a "Master" workbook that creates an actual copy of each worksheet and places it within.

    Now from here, I have the following VBA to grab each Table and its information to compile it into one list under another worksheet titled "Summary." Here is the VBA inserted in the module:

    -----
    Option Explicit

    Sub Consolidate()
    Dim NR As Long, ws As Worksheet, wsA As Worksheet
    If MsgBox("Create Summary Report from all worksheets?", _
    vbYesNo + vbQuestion) = vbYes Then
    On Error GoTo ErrorHandler
    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Sheets("Summary").Activate
    Set wsA = ActiveSheet
    Range("A2", Range("A2").SpecialCells(xlCellTypeLastCell)).ClearContents
    NR = 2

    For Each ws In Sheets(Array("Barb", "Cecilia", "Gus", "Mary", "Yi", "Vacant"))
    ws.Activate
    Range("A2", Range("A2").SpecialCells(xlCellTypeLastCell)).Copy wsA.Range("A" & NR)
    NR = wsA.Range("A1").End(xlDown).Row + 1
    Next ws
    End If
    wsA.Activate
    Set wsA = Nothing
    ResetAll:
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Exit Sub

    ErrorHandler:
    MsgBox Err.Number & " - " & Erl & " - " & Err.Description
    Resume ResetAll

    End Sub

    -----

    This code works; to a degree I believe

    ISSUE: When I have the following VBA for when the workbook opens it creates the table but when I refresh all the data, because I am using a pivot table and a COUNTA function for the "Summary" table, it breaks the linkages to the data and isn't necessarily operations friendly. If I were to solely use it the issues could just be worked around, but as you know, creating a workbook for a team really needs to be 'full-proof.'

    Option Explicit
    Private Sub Workbook_Open()

    Application.OnTime Now() + TimeValue("00:00:03"), "Consolidate"
    ThisWorkbook.RefreshAll

    End Sub

    'NOTE for excel help forum people, I have a delay of 3 seconds because it helps it run a little smoother, especially as this workbook is liked to others
    ----

    If you could help me or guide me in anyway, I would greatly appreciate it. I am a relative newbie to VBA, so plain language and patience is always appreciated.

    Regards,

    Chris

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Consolidated workbook to VBA worksheet table merge followed by refresh data

    Make your summary table a real Excel Table and use that as the data source for the pivot table. Once linked to an Excel Table, a pivot table becomes aware of the range no matter how many rows the Excel Table has, or how many columns for that matter.

    Here's an introduction to Excel Tables: http://www.utteraccess.com/wiki/inde...ables_in_Excel

    To clear out the contents of the table before concatenating the subordinate sheets in, use the following code:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Re: Consolidated workbook to VBA worksheet table merge followed by refresh data

    Thank you for the tip about having the pivot table reference the NAME of the table oppose to the range, simple and effective solution.

    Regarding the VBA you provided me, it is not not working. I am having a Run Time Error 438 "Object does not support this property or method." I've tried searching the web for solutions and have come across the VBA.

    I've removed the wsa.Activate in the later part of the VBA and it seems to be addressing my issue, but now I need it to return to the activesheet :|

    Any ways, thank you.

+ 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. Multiple text files listed in a worksheet and the data to consolidated in a worksheet
    By balaji.rk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2015, 07:41 PM
  2. [SOLVED] Merge Certain Worksheets Into Consolidated Tab
    By Montoro22 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-07-2015, 10:17 AM
  3. [SOLVED] Refresh data table filters on worksheet activation
    By BuZZarD73 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2014, 06:45 AM
  4. need to extract data from several worksheets to a consolidated worksheet.
    By keyboardwarrior in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2014, 02:03 AM
  5. [SOLVED] Macro to consolidated all data from different sheets to summary sheet in the same workbook
    By rochakmehta90 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2013, 03:10 AM
  6. [SOLVED] Excel macro to search a particular workbook and copy data to consolidated
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-11-2013, 10:34 AM
  7. Copy data from multiple workbooks into consolidated/master workbook
    By mobro1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-02-2012, 02:42 PM

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