+ Reply to Thread
Results 1 to 6 of 6

Tweak Copy/Paste Special Macro based on conditions

  1. #1
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Question Tweak Copy/Paste Special Macro based on conditions

    Hi all,

    I found the script below (which works great), however, I would like to tweak it to:

    1) Check against a value on worksheet "settings" in cell C3 (this is a dropdown where you can select from a range of values)
    2) Then, depending on the value selected, special copy/paste from various worksheets and cells

    Please Login or Register  to view this content.
    I've attached an example spreadsheet. Hope this helps!

    In total, there will be approx. 100 cells to copy over (example only holds 1) for each value you can select. So the script should accommodate for that. E.g. if value Template 1 is selected, copy 100 cells from worksheet Template1. If Template 2 is selected, copy 100 cells from worksheet Template2.

    The copy/paste should be special (as in the existing script) so can't work with formulas here, I'm afraid.
    Not quite sure where to start with this so would appreciate any help!
    Many thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Tweak Copy/Paste Special Macro based on conditions

    Start by modifying the tab names for "Template1" and "Template2" to "Template 1" and "Template 2" so that there is a space before the number. This will make the sheet names the same as those in the drop down list. Then copy and paste this macro into the worksheet code module. Do the following: right click the tab for your "Template" sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make a selection in C3. You can delete your current macro as it is no longer necessary.

    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Tweak Copy/Paste Special Macro based on conditions

    Awesome!!! That works perfectly Thank you so much!

    Only question I have, if there are more values/cells to copy over (i.e. up to 100), what would I need to tweak?
    Example: if Template 1 is selected, then copy/paste cell C3 into C6 and C4 into C7 and... all from worksheet Template 1 (or Template 2 etc. depending on what is selected). In the end I'll have approx. 20 values in the dropdown and therefore 20 worksheets to copy up to 100 cells over for each.
    Hope that makes sense?

    Many thanks for your help!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Tweak Copy/Paste Special Macro based on conditions

    Try the attached file. I had to unmerge the cells in the "Template" sheet. You should avoid using merged cells if at all possible because they cause havoc for Excel macros.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-25-2015
    Location
    London
    MS-Off Ver
    MS 365
    Posts
    213

    Re: Tweak Copy/Paste Special Macro based on conditions

    Awesome! That seems to do the trick! Thanks so much! I owe you a cyber beer!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Tweak Copy/Paste Special Macro based on conditions

    You are very welcome. If I'm ever in London, I'll take you up on that.

+ 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] Tweak Code for Copy and Paste Special vs Cut and Paste
    By Adam Schaefer in forum Excel General
    Replies: 1
    Last Post: 04-18-2016, 11:12 AM
  2. A Copy & Paste Special macro...
    By arminyack in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2014, 08:58 AM
  3. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  4. Macro to copy/paste special based on date
    By lateforwork2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2012, 07:26 PM
  5. Copy & Paste Special Values in Row Based on Date
    By mrfibbers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2012, 05:33 AM
  6. Copy/Paste Special Macro
    By TheNewGuy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-23-2009, 03:46 PM

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