+ Reply to Thread
Results 1 to 3 of 3

Merge data on different sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    athens
    MS-Off Ver
    Excel 2007
    Posts
    43

    Merge data on different sheets

    Hi everyone,
    I want to bring all the data from specific different sheets in a single new sheet. The data is in the same format as shown in the attached file.
    However, I need only the data from the two first sheets to be merged and every time that these data change, an updated "merge sheet" to appear.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Merge data on different sheets

    Try this code - Ensure that you remove the ending space in the sheetname "1st & 3rd Saturday".
    Option Explicit
    
    Sub update_sheets()
    Dim mysheet As Variant
    Dim lrow As Long
    
    Application.ScreenUpdating = False
    
    If Evaluate("ISREF(Summary!A1)") Then
        Worksheets("Summary").Delete
    End If
    
    Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = "Summary"
    Worksheets("Summary").Range("A1:E1").Value = Split("Site, Origin,Destination, Period, OW/RT", ",")
    
    For Each mysheet In Array("1st & 3rd Saturday", "2nd & 4th Saturday")
        With Sheets(mysheet)
            lrow = .Range("A" & .Rows.Count).End(xlUp).Row
            If lrow > 2 Then .Range("A2:E" & lrow).Copy Worksheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
        End With
    Next mysheet
    
    MsgBox "Summary updated"
    
    Application.ScreenUpdating = True
    
    End Sub
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    athens
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Merge data on different sheets

    It works perfect!
    thanks a lot Arlette!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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