Results 1 to 5 of 5

Copy & Paste based on value into other workbook

Threaded View

KerahJoy Copy & Paste based on value... 10-05-2023, 11:14 AM
MikeVol Re: Copy & Paste based on... 10-05-2023, 03:46 PM
KerahJoy Worked perfectly…..thank you... 10-09-2023, 03:59 PM
Marc L Try this ! 10-07-2023, 11:55 AM
MikeVol Re: Copy & Paste based on... 10-10-2023, 11:21 AM
  1. #1
    Forum Contributor
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    109

    Copy & Paste based on value into other workbook

    I posted this before but modified it since my original ask had too many steps.

    I have a sourcedata wb SourceData FY24 and a destination wb Destination FY24.
    Within wb Destination FY24, ws Mission Control, and cell "B3" there is a name listed which I want to use to filter the range to copy. Steps wanted:

    1. Clear all data from cells "AF2 to BW10" in ws Mission Control of wb Destination FY24. Code must be dynamic since table size can change.
    2. Copy only rows from wb SourceData FY24 and ws SourceData that match value in "B3" of Destination FY24.
    3. Paste copied data into Destination FY24 starting in cell "AF2".

    My current code does not work fully and need feedback:

    Sub Insert_SC()
    
    Application.ScreenUpdating = False
    
    Dim wbSource As Workbook
    Dim wbDest As Workbook
    Dim wsSource As Worksheet
    Dim wsDest As Worksheet
    Dim SourceRng As Range
    Dim NameRng As Range
    Dim DestRng As Range
    Dim DestLastRow As Long
    
    Workbooks.Open ("C:\Users\kerah\SourceData FY24.xlsx")
    Workbooks.Open ("C:\Users\kerah\Destination FY24.xlsx")
    
    Set wbSource = Workbooks("SourceData FY24.xlsx")
    Set wbDest = Workbooks("Destination FY24.xlsx")
    Set wsSource = wbSource.Worksheets("SourceData")
    Set wsDest = wbDest.Worksheets("Mission Control")
    Set SourceRng = wsSource.Range("E1").CurrentRegion
    Set NameRng = wsDest.Range("B3").CurrentRegion
    Set DestRng = wsDest.Range("AF1:BW1")
    
        DestLastRow = wsDest.Cells(wsDest.Rows.Count, "AF").End(xlUp).Offset(1).Row
        wsDest.Range("AF2:BW" & DestLastRow).ClearContents
        SourceRng.AdvancedFilter xlFilterCopy, NameRng, DestRng
        wbDest.Save
        wbDest.Close
    
        
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 02-16-2018, 06:40 PM
  2. Copy & Paste from Workbook A to Workbook B Based on Date and value of cell
    By Jalica in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-16-2018, 01:29 AM
  3. Copy and paste based on criteria in another workbook
    By phbragan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2017, 11:59 PM
  4. Copy and Paste Data from one Sheet to Other on different workbook based on Criteria
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2016, 03:25 PM
  5. [SOLVED] Copy column based on info in first row and paste into new workbook via macro
    By painterartist in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2014, 11:45 AM
  6. Copy and paste entire row based on text in row A to new workbook.
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2013, 04:53 PM
  7. Copy a range based on dynamic row numbers and paste into another workbook
    By Grizz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2013, 02:07 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