Results 1 to 4 of 4

Consolidating several sheets data

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2015
    Location
    St.Paul, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    37

    Consolidating several sheets data

    Hi, i've got a code that consolidates all of the data within several sheets in a workbook, and creates a new sheet titled "Combined" with all the compiled data. It also trims the data (removes a couple unnecessary columns and rows) and does a few other tweaks to make it look more presentable. However, as I must update this data every month, I've noticed an error with my new data not being properly combined. The error i'm seeing is this: All of sheet 1 is properly copied and pasted, except beginning at sheet 2, the FIRST row of data is not copied over and the LAST row of data is only copying a portion. This error seems to repeat throughout the rest of the sheets. Here's my code:
    Sub Test()
        Dim SH As Worksheet
        Dim J As Integer
        Application.ScreenUpdating = False
            For Each SH In ThisWorkbook.Sheets
                SH.Rows("1:3").EntireRow.Delete
                SH.Columns("A:B").EntireColumn.Delete
                SH.Columns("E:E").EntireColumn.Delete
                SH.Cells.UnMerge
            Next
            
        On Error Resume Next
        Sheets(1).Select
        Worksheets.Add ' add a sheet in first place
        Sheets(1).Name = "Combined"
    
        ' copy headings
        Sheets(2).Activate
        Range("A1").EntireRow.Select
        Selection.Copy Destination:=Sheets(1).Range("A1")
    
        ' work through sheets
        For J = 2 To Sheets.Count ' from sheet 2 to last sheet
            Sheets(J).Activate ' make the sheet active
            Range("A1").Select
            Selection.CurrentRegion.Select ' select all cells in this sheets
    
            ' select all lines except title
            Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    
            ' copy cells selected in the new sheet on last line
            Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
        Next
       
       With Worksheets("Combined")
            .Columns("A:D").EntireColumn.AutoFit
            .Columns("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
            .Columns("A:A").SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
        End With
    End Sub
    The attachment is made with dummy data that hopefully portrays the issue, however the code should not be ran on this attachment, it will not work properply, rather I'll explain the results of the code with my original file.

    After the above code is ran, all of sheet 1 is copied properly into the new "Combined" sheet, but note starting at SHEET 2, COMPANY 23 is not included in the combined sheet, and yet it skips it and continues with COMPANY 24 then towards the bottom of SHEET 2, COMPANY 67 name is copied properly, but only ITEM REQUIRED 90 is pasted into the combined sheet. This error seems to replicate throughout.

    Any help is greatly appreciated!! Thanks!

    Mark excel tickler.xlsx
    Last edited by murp5972; 08-05-2015 at 10:26 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. consolidate the all the data to one sheet
    By sriku in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-29-2014, 01:22 PM
  2. [SOLVED] Match Issue - Consolidate Columns of Data With Match/Index/etc?
    By excelsior123 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-03-2014, 05:14 PM
  3. [SOLVED] VBA to consolidate/match data within a sheet
    By nawGo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2014, 03:27 PM
  4. Consolidate Data from one sheet
    By esperanto in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-18-2013, 02:57 AM
  5. [SOLVED] Consolidate Data from 1 Range on 1 Sheet in Multiple Workbooks to Master Workbook Sheet
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 06:11 AM
  6. [SOLVED] Consolidate data from multiple sheet to one sheet
    By kesavanprabhu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2013, 10:30 AM
  7. Kindly assist to consolidate data from raw data sheet to report sheet
    By ejima in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-30-2012, 10:11 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