+ Reply to Thread
Results 1 to 5 of 5

Copy & Paste based on value into other workbook

  1. #1
    Registered User
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    94

    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:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    304

    Re: Copy & Paste based on value into other workbook

    Hello @KerahJoy. Maybe so?
    Please Login or Register  to view this content.
    Good Luck.
    Last edited by MikeVol; 10-07-2023 at 01:01 PM. Reason: Update

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    Quote Originally Posted by KerahJoy View Post
    My current code does not work fully
    Just well reading at least the error message you should have seen you have forgotten to unprotect the worksheet ‼

    According to your attachment removing the useless and adding the missing a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
      Const 
    "1234"
        
    Dim D$, S$, Ws As Worksheet
            D 
    "D:\Tests4Noobs\KerahJoy\Destination FY24.xlsx"
            
    Replace$(D"Destination""SourceData")
            If 
    Dir(D) = "" Or Dir(S) = "" Then Beep: Exit Sub
            Application
    .ScreenUpdating False
            Set Ws 
    Workbooks.Open(D0).Worksheets(1)
            
    Ws.Unprotect P
            Ws
    .[AF1].CurrentRegion.Offset(1).ClearContents
       With Workbooks
    .Open(S0)
           .
    Worksheets(1).ListObjects(1).Range.AdvancedFilter 2Ws.[B2:B3], Ws.[AF1:BW1]
           .
    Close False
       End With
            Ws
    .Protect P
            Ws
    .Parent.Close True
            Application
    .ScreenUpdating True
            Set Ws 
    Nothing
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 10-10-2023 at 12:12 PM. Reason: adding error comment ...

  4. #4
    Registered User
    Join Date
    03-12-2022
    Location
    Atlanta, Georgia
    MS-Off Ver
    365
    Posts
    94
    Quote Originally Posted by MikeVol View Post
    Hello @KerahJoy. Maybe so?
    Please Login or Register  to view this content.
    Good Luck.

    Worked perfectly…..thank you Mike!!!

    Can you show me a slight modification to your code to not require the filter and copy all active data from source? I have 2 workbooks that require different kind of data pull……

  5. #5
    Valued Forum Contributor
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    304

    Re: Copy & Paste based on value into other workbook

    Hello @KerahJoy. If the structure of the book does not differ from the current examples that you provided in the first post, then you can use the following code:
    Please Login or Register  to view this content.
    If the structure of the books is different, then this code will not work correctly. Good luck.

+ 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. 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