+ Reply to Thread
Results 1 to 2 of 2

Copy Data from multiple sheets based on criteria in a column and paste to master log.

  1. #1
    Registered User
    Join Date
    07-15-2014
    Location
    Denver, CO
    MS-Off Ver
    2010
    Posts
    2

    Angry Copy Data from multiple sheets based on criteria in a column and paste to master log.

    I have a workbook that contains multiple sheets and Two Master sheets. I am trying to get specific data (Depending on what is in Column "G") from specific sheets to go to one Master Log, and data with a different criteria (Also in Column "G") to go to a different sheet. I have a version of the code typed out But I keep getting Run-time error 7 : Out of Memory. I duplicated the Module to do the exact same thing but changed the destination of the copied data to the other Master sheet, and still no luck.

    Please review this code and see if there is any changes I can make to get this thing working.

    Public Sub CombineDataFromAllSheets()
    Dim wkstSrc As Worksheet, wkstDst As Worksheet
    Dim i As Integer
    Dim LastRow As Long, erow As Long

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Set wkstDst = ThisWorkbook.Worksheets("Master Supplemental Requests")

    For Each wkstSrc In ThisWorkbook.Worksheets
    If wkstSrc.Name <> "Master Supplemental Requests" _
    And wkstSrc.Name <> "State Recap" _
    And wkstSrc.Name <> "Division" _
    And wkstSrc.Name <> "Master Sales Projection" _
    And wkstSrc.Name <> "JDA NIF" _
    And wkstSrc.Name <> "Instructions" _
    And wkstSrc.Name <> "items" _
    And wkstSrc.Name <> "Item Forecast" _
    Then

    'Define Variables and run the copy Paste events
    LastRow = wkstSrc.Cells(Rows.Count, 1).End(xlUp).Row
    For i = 21 To LastRow

    If wkstSrc.Cells(i, 8) = "Supp" _
    And wkstSrc.Cells = "Both" Then

    wkstSrc.Cells(i, 1).Copy
    erow = wkstDst.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
    wkstDst.Cells(erow, 3).PasteSpecial xlPasteValues

    wkstSrc.Cells(i, 9).Copy
    wkstDst.Cells(erow, 5).PasteSpecial xlPasteValues

    wkstSrc.Cells(i, 10).Copy
    wkstDst.Cells(erow, 6).PasteSpecial xlPasteValues

    wkstSrc.Cells(i, 11).Copy
    wkstDst.Cells(erow, 7).PasteSpecial xlPasteValues

    wkstSrc.Cells(i, 12).Copy
    wkstDst.Cells(erow, 15).PasteSpecial xlPasteValues

    wkstSrc.Cells(i, 13).Copy
    wkstDst.Cells(erow, 16).PasteSpecial xlPasteValues

    wkstDst.Cells(erow, 4).Value = wkstSrc.Name
    End If
    Next i

    End If

    Next wkstSrc

    Application.CutCopyMode = False
    Application.EnableEvents = True
    Application.ScreenUpdating = True


    End Sub

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Copy Data from multiple sheets based on criteria in a column and paste to master log.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.
    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.
    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

+ 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. Copy multiple columns and paste into one column, based on row criteria
    By Miki1989 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2015, 09:59 AM
  2. [SOLVED] Create new sheets from master sheet based on multiple column criteria
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2015, 02:44 PM
  3. Replies: 11
    Last Post: 05-12-2013, 11:30 AM
  4. Copy and paste data to separate sheets based on mutiple criteria again
    By Ricker090 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-13-2011, 02:23 PM
  5. Copy and paste data to separate sheets based on mutiple criteria
    By Ricker090 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2011, 03:48 PM
  6. MS Excel 2003 macro to copy paste data in different sheets based on certain criteria
    By bhaktprahlad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2010, 06:17 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