+ Reply to Thread
Results 1 to 18 of 18

Dynamic copy & paste according to multiple criteria

  1. #1
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Dynamic copy & paste according to multiple criteria

    Hi all - I really appreciate the help in advance.

    I am stuck with the following problem.

    Sheet2 shows a list of prices for a derivative contract for a set of tenures (Jun22, Jul22, Aug22 ... etc.). This data is pulled through from another worksheet via VLOOKUP and INDEX MATCH formulas.

    At the end of each day, I want to create a macro that takes these prices from Sheet2 and stores them into Sheet3 once the macro is run. I require the data from Sheet2 to be put into the correct tenure (columns) and to the correct date (rows). The desired output for 20/05/2022 is displayed in Sheet3.

    I have previously solved this using a macro to copy and transpose the data, however it is only a short term solution as the tenures are changing as time goes along. For example Jun22 will expire and be made redundant at the end of May and this means that it requires regular checking to ensure the correct data is put into the correct row/column and issues are caused when a contract expires.

    Note
    1) The format of the data in the tenures column in both Sheet2 and Sheet3 is in text and not as a date. This has to stay this way because of how data is pulled into my worksheets both between different sheets and through external RTD sources and workbooks.
    2) The data in Sheet2 changes daily and is taken from various other Sheets in the same workbook via VLOOKUP and INDEX MATCH formulas

    Please let me know if further explanation is needed!
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,824

    Re: Dynamic copy & paste according to multiple criteria

    Administrative Note:

    Welcome to the forum.

    Members will tailor the solutions they offer to the version (NOT a release number like 2020) of Office (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,199

    Re: Dynamic copy & paste according to multiple criteria

    Try

    in B3

    =INDEX(Sheet2!$B$4:$B$12,MATCH($A3,Sheet2!$B$2:$Z$2,0)+MATCH(Sheet3!B$1,Sheet2!$A$4:$A$12,0)-1)

    It is not clear how date is put in Sheet3 nor whether there can be more than one date entry on Sheet2
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    Hi John thank you for the response.

    Unfortunately the data in Sheet2 is constantly changing and is being pulled in live via an RTD function. I need the cell B3, B4 etc to represent a snapshot of this data when the macro is run and store the data in Sheet3 according to the correct tenure and date.

    I am sorry if the explanation above wasn't clear.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,824

    Re: Dynamic copy & paste according to multiple criteria

    Please update your forum profile, as I requested above. Thanks.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,199

    Re: Dynamic copy & paste according to multiple criteria

    data in Sheet2 is constantly changing
    Please show examples of what is changing and how.

    The formula will handle changing data.
    Last edited by JohnTopley; 08-24-2022 at 03:24 PM.

  7. #7
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    Apologies for not being clear.

    In Sheet2 the data for each tenure is pulled from an external source via an RTD Function and is near enough changing every second.

    The formula above works, however the following day and going forward I imagine it will start to read N/A as the date in reference is now in the past.

    Cell B2 in Sheet2 will have a =Today() formula.

    What I require is a snapshot of the values at a certain point everyday such that each value is copied from Sheet2 and pasted into Sheet3 as values under the correct tenure column (Jun22, Jul22 .. etc.) and in the correct date row (which will always be today).

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    Macro code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  9. #9
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    kvsrinivasamurthy thank you so much - that has worked for the initial sample.

    I am finding an issue when I have to add periods to both Sheet2 and Sheet3 (see attached).

    In this example, the Jun22, Jul22 and Aug22 have been made redundant and so have no values. I have added Oct22 Nov22 Dec22 Jan23 Feb23 and Q2 23 to both sheets.

    Upon executing the macro, the values for some are correct but other periods are going into incorrect boxes.

    Sorry to keep pestering and I really appreciate you taking the time to look at this.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    Corrected Code:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    kvsrinivasamurthy this is fantastic thank you so much for the help!

    I am working through the code to try and learn and understand this for myself so I can apply it in practice now.

    Your help is very much appreciated.

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    Welcome. Thanks for feed back.

  13. #13
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    Hi - can I ask one more thing if possible?

    Is it ok to provide comments for each step of the above code? I am sorry to be a pest - I need to adapt the solution now to a new sheet which slightly differs in format and really want to work it out for myself!

    Thank you again for your help.

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    I have added comments in the code. Pl see file.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    Hi kvsrinivasamurthy

    Can you send the code on here if possible as my work PC cannot allow me to open the file with macros.

    Thank you again for your help sir.

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    Code:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    08-23-2022
    Location
    London, England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2206 Build 16.0.15330.20144) 32-bit
    Posts
    8

    Re: Dynamic copy & paste according to multiple criteria

    thank you very much for helping to solve my problem!

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Dynamic copy & paste according to multiple criteria

    Welcome. Thanks for feedback.

+ 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. [SOLVED] Copy & Paste Macro (needs finishing) - multiple Criteria
    By Dan_B in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2017, 05:18 PM
  2. Copy and Paste multiple lines with the same criteria in one cell
    By CassieW in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2016, 04:31 PM
  3. [SOLVED] Copy rows from multiple worksheets with multiple criteria - greater than dynamic values
    By stackout in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2015, 04:36 PM
  4. [SOLVED] Copy/Paste Multiple Dynamic Ranges below each other
    By sudric in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-28-2015, 10:13 AM
  5. Copy/Paste Formula for Multiple Criteria
    By quibilty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2014, 11:07 PM
  6. VBA Copy Column data based on multiple dynamic criteria
    By rotolytics in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2011, 07:26 PM
  7. Replies: 1
    Last Post: 09-22-2010, 11:00 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