+ Reply to Thread
Results 1 to 7 of 7

Consolidate Worksheets - Help pasting values

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Consolidate Worksheets - Help pasting values

    Dear experts,

    I am having trouble tweaking the code below. I need to paste values and formats to a new workbook (so the one i'm copying from stays intact).

    Sub CombineWorksheets1()
    Dim Ws As Worksheet
    Application.ScreenUpdating = False
    Sheets(1).Select
    Worksheets.Add
    With Sheets(1)
        .UsedRange.Offset(1).Clear
    For Each Ws In Worksheets
      If .Index <> Ws.Index Then Ws.UsedRange.Offset(1).Copy .Cells(.Rows.Count, 1).End(xlUp)(2)
      Application.CutCopyMode = False
    Next
        Application.GoTo .Cells(1), True
    End With
        Application.ScreenUpdating = True
    End Sub
    Ty

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Consolidate Worksheets - Help pasting values

    Try change to
                If .Index <> Ws.Index Then
                    Ws.UsedRange.Offset(1).Copy
                    .Cells(.Rows.Count, 1).End(xlUp)(2).PasteSpecial xlPasteFormats
                    .Cells(.Rows.Count, 1).End(xlUp)(2).PasteSpecial xlPasteValues
                    Application.CutCopyMode = False
                End If

  3. #3
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Consolidate Worksheets - Help pasting values

    Hi Jindon!
    Thank you for replying. I tested it, but i got an error due to merged cells.
    Also, to be safe, instead of pasting to a new sheet how do paste it to a new workbook?
    Ty.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Consolidate Worksheets - Help pasting values

    Then how about
    Sub CombineWorksheets1()
        Dim Ws As Worksheet
        Application.ScreenUpdating = False
        With Workbooks.Add.Sheets(1)
            For Each Ws In ThisWorkbook.Worksheets
                Ws.UsedRange.Offset(1).Copy .Cells(.Rows.Count, 1).End(xlUp)(2)
                .UsedRange.Value = .UsedRange.Value
                Application.CutCopyMode = False
            Next
            Application.GoTo .Cells(1), True
        End With
        Application.ScreenUpdating = True
    End Sub

  5. #5
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Consolidate Worksheets - Help pasting values

    Quote Originally Posted by jindon View Post
    Then how about
    Sub CombineWorksheets1()
        Dim Ws As Worksheet
        Application.ScreenUpdating = False
        With Workbooks.Add.Sheets(1)
            For Each Ws In ThisWorkbook.Worksheets
                Ws.UsedRange.Offset(1).Copy .Cells(.Rows.Count, 1).End(xlUp)(2)
                .UsedRange.Value = .UsedRange.Value
                Application.CutCopyMode = False
            Next
            Application.GoTo .Cells(1), True
        End With
        Application.ScreenUpdating = True
    End Sub
    I get an error 6 'overflow' problem, highlighting .usedrange line.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Consolidate Worksheets - Help pasting values

    What happen if move that line to outside loop.
    i.e
            For Each Ws In ThisWorkbook.Worksheets
                Ws.UsedRange.Offset(1).Copy .Cells(.Rows.Count, 1).End(xlUp)(2)
                Application.CutCopyMode = False
            Next
           .UsedRange.Value = .UsedRange.Value
    If you still have problem, you need to upload a workbook.

  7. #7
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Consolidate Worksheets - Help pasting values

    It works for some wkbooks and gives an error for others.
    Anyways, I gets the job done. Thank you so very much
    Last edited by exc4libur; 09-18-2016 at 09:59 PM.

+ 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. Pasting values from multiple worksheets into master worksheet
    By ppp112 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2016, 10:52 AM
  2. Need to consolidate worksheets based of values listed under a name
    By talltxn33647 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 11-12-2015, 11:13 PM
  3. [SOLVED] Copying different values from different cells, and pasting into different worksheets
    By farhan13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-02-2014, 06:07 AM
  4. [SOLVED] Pasting links from the other worksheets instead of values
    By Nikotino in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2013, 05:21 AM
  5. Replies: 3
    Last Post: 02-25-2013, 08:11 AM
  6. Copying and pasting worksheets into new worksheet as values
    By MikeFranz123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2012, 05:42 AM
  7. Replies: 1
    Last Post: 06-23-2009, 06:19 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