+ Reply to Thread
Results 1 to 6 of 6

Archive/Transfer data from multiple sheets into one sheet with criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    11-11-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    47

    Archive/Transfer data from multiple sheets into one sheet with criteria

    May I ask if I have 2 sheets that of "Disposed" items that required to be moved, what would the VBA like?
    Please find the attached Excel. I want the rows in Sheet 3 and Sheet 1 with "Disposed", being transferred to Sheet 2, and having the disposed items removed from Sheet 3 and 1.

    I expected the red labelled "Disposed" rows in sheet 3 and 1 to be moved to sheet 2, followed by deleting the disposed items in sheet 3 and 1.

    Thanks!

    Ken
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Archive/Transfer data from multiple sheets into one sheet with criteria

    Hello Ken,

    Not a lot different from your last thread, only this time we reference all the source sheets:

    Option Explicit
    Sub TestKen()
    
            Dim ws As Worksheet
    
    Application.ScreenUpdating = False
    
            For Each ws In Worksheets
                    If ws.Name <> "Sheet2" Then
                            With ws.[A1].CurrentRegion
                                    .AutoFilter 3, "Disposed"
                                    .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
                                    .Offset(1).EntireRow.Delete
                                    .AutoFilter
                            End With
                    End If
            Next ws
    
    Application.ScreenUpdating = True
    
    End Sub
    I hope that this helps.

    Cheerio,
    vcoolio.

  3. #3
    Registered User
    Join Date
    11-11-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    47

    Re: Archive/Transfer data from multiple sheets into one sheet with criteria

    Thanks again. If you don't mind, can you explain briefly what do the following items mean?

    Option Explicit
    Sub TestKen()

    Dim ws As Worksheet

    Application.ScreenUpdating = False

    For Each ws In Worksheets
    If ws.Name <> "Sheet2" Then
    With ws.[A1].CurrentRegion
    .AutoFilter 3, "Disposed"
    .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
    .Offset(1).EntireRow.Delete
    .AutoFilter
    End With
    End If
    Next ws

    Application.ScreenUpdating = True

    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Archive/Transfer data from multiple sheets into one sheet with criteria

    Hello Ken,

    With this line of code:-

    With ws.[A1].CurrentRegion
    CurrentRegion refers to your dataset beginning at cell A1. This can also be written as:-

    With ws.Range("A1").CurrentRegion
    or

    With ws.Cells(1,1).CurrentRegion
    With this line of code:-

    .AutoFilter 3, "Disposed"
    The 3 stands for Column C, which, in this case, means the filter is placed on Column C filtering for the criteria "Disposed".

    The End(3)(2) in this line of code:-

    .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
    are simply the enumerations for xlUp which is the (3) and offset(1) which is the (2).

    It is the same as writing:

    .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1,0)
    or
    .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(xlUp) (2)
    So the rows are counted from the bottom of the sheet (the very last row, Column A) upwards to the last used row of data then offset one row down from the last row to avoid overwriting previous rows of data.

    I hope that this helps.

    Cheerio,
    vcoolio.
    Last edited by vcoolio; 07-24-2021 at 12:00 AM.

  5. #5
    Registered User
    Join Date
    11-11-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    47

    Re: Archive/Transfer data from multiple sheets into one sheet with criteria

    Thank you so much for your time for explaining this! It all makes sense!

  6. #6
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Archive/Transfer data from multiple sheets into one sheet with criteria

    You're welcome Ken. I'm glad to have been able to assist.

    Cheerio,
    vcoolio.

+ 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. Archive/Transfer data to a sheet based on specific text
    By kehong216 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2021, 08:30 AM
  2. [SOLVED] Archive data from a master sheet to corresponding sheets
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2020, 11:27 AM
  3. How to transfer data from multiple sheets into 1 sheet
    By plumberef in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-08-2019, 12:42 PM
  4. Transfer Data from one sheet to 2 other sheets based on criteria gets stuck mid-sub
    By shortytoo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2018, 12:18 PM
  5. [SOLVED] Transfer specific data from various sheets depending on multiple criteria
    By ulothar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2018, 12:11 PM
  6. Transfer data Specific a row from multiple sheets to another sheet
    By salmasaied in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2016, 02:23 AM
  7. Macro to Transfer data from multiple sheets into rows on a master sheet
    By serrone in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2013, 06:35 AM

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