+ Reply to Thread
Results 1 to 29 of 29

Copy paste region to another exact location(s)

  1. #1
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Copy paste region to another exact location(s)

    Hi

    I am trying to copy a select set of data to another tab (sheet2). The data on sheet1 consists of 4 columns. Column1 is a set of candidate pictures, columns 2,3,4 are the candidate scores.

    Sheet 2 is almost set up like a template with pre-marked areas for which the data needs to be pasted into. The scores are pasted underneath pictures.

    For now I have pre-marked the areas on sheet 2 but long term if the data on sheet 1 increases, I don't know if it's possible to create new areas /enlarge template on sheet 2 'on the fly' ?

    I have attached my worksheet and made some progress. I have also shown some examples of what the data would look like on sheet2.

    Also, I don't want the pictures once pasted to increase the size of the (middle) cells they are being pasted into. They pictures are 3x5 cells in size so will take up 3x5 cells.

    Could anybody have a look and offer any help?
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Hi

    Thanks for the reply.

    Did you see sheet2 on the attachment? If not, I think it makes things clearer.

    If not please let me know and I will post again.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    You can use Vlookup.
    You could keep the picture name beneath the picture. Just like you have it.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then copy range K12:M12 and paste formulas into q12,w12,h19,n19.....ect

  4. #4
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Hi

    I have re-attached and the sheet2 tab shows an example of the finished result. Where it says .jpg1, jpg2 etc. that's where the pictures would reside.

    Hope that's clearer but if I have missed anything please let me know.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Hi dave

    Thanks for the idea. Ideally I wanted it all automated via a macro as the list on sheet 1 can grow and it's just time consuming have to copy paste all the time. BTW the .jp1, jpg2 etc. on sheet2 was just typed there to show that that's where the picture sits. There is no text there in actuality … just a picture.

    I set up the template on sheet 2 and think I could use an array function with the .offset feature? I have seen it done before but not 100% how to code it. Still new and learning.
    Last edited by technik; 11-30-2019 at 09:29 AM.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    You attached sample workbook, click on the pictures to see the picture name.

    The code will loop through the pics and search sheet 1 for the picture name, then place the data in the correct cells.

    Click the button.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by davesexcel; 11-30-2019 at 10:09 AM.

  7. #7
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Thanks Dave - that's a great help.

    Could you take a look at the workbook again. I've placed the pics on sheet1 as that's their starting location. From there they (and the corresponding data) are to be copied to the 'With Pics' tab.

    I'm a little confused with the output at the moment.
    Attached Files Attached Files

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    I will have to get back to this, I have to go out.

    You can loop through the cells and identify specific cells with specific borders.

    I have just worked out this code, it will loop through the cells and color the ranges that will have the pics.

    Test it out! Now we have a way to find the picture ranges.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    That's pretty cool Dave and is at least a very good start.

    I am developing this further (and have realised this may be trickier than I first thought) so I think it's best to let you know now that I have groups of data that need copying into a venn diagram type of template. The challenge I have is understanding the code so that if my the candidate list was to grow (due to candidate numbers) then I could easily adapt the code to suit.

    Could you have a look at the attached. What I would appreciate is … if it's a big task and onerous then I may have to look at doing this a different way... but I am hoping that a few macros will just copy the photos into the correct location.

    Again - thanks for all your help.
    Attached Files Attached Files

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    There is some prep work to do 1st

    1- name the group ranges.( do this manually)

    2-loop through the pictures and name them
    3-Name the ranges in Sheet(2) so we know where to paste the pictures.
    4-loop through the pictures and compare named ranges to see if they match. (If there are more picture names than range names you will get a message and will need to fix before copy and pasting the pics.)
    5-copy and paste pictures to the named ranges and get the info for each picture.

    As of right now, you have 9 pictures for group 4 in sheet(1), but only have 8 ranges in group 4 sheet(2),
    so the message-box will pop up telling you, you have to fix this then run the code again.

    -
    Code to name the pictures.
    Please Login or Register  to view this content.
    -

    Code to create the named ranges for the pics to be pasted in.
    Please Login or Register  to view this content.
    Name Group1.jpg
    Name the pictures.jpg
    NamePicRanges.jpg
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Thanks a bunch for this Dave... will test and feedback

    Thanks again !

  12. #12
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Hi Dave

    Was copying code across to my master template sheet and everything 'was' going fine .. until I hit an error and cannot for the life of me work out why it's giving me the error. I've walked through it and the same error does not occur on your sheet .. so I'm lost now. Have spent ages on it with no joy. Could you take a look? Sheet attached.


    Many thanks once again
    Attached Files Attached Files

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    It looks like you haven't completed the 1st part of my instructions. Naming the group ranges., you have to do this manually.

    Name them according to the sample I gave you, the code will be looking for those group names.

    Go through the sample workbook and look at the named ranges, there are named ranges for the groups in sheets 1 & 2

    Note: The top of the pictures cannot over lap into another cell
    Last edited by davesexcel; 12-02-2019 at 02:21 PM.

  14. #14
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Ok thanks dave.. think I've done that properly now however can you tell me if I have the candidate name and number to the left of (each) photo on each group do I need to adjust this line of code below (e.g. 1. - John Smith - PHOTO - Score 1 - Score 2 - Score 3) when looping through to name the pics?

    Please Login or Register  to view this content.
    as I am getting a 'no cells were found' error when trying to loop through and name the pics

    thanks
    Last edited by technik; 12-02-2019 at 05:34 PM.

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    The code was designed for the sample you provided, you had changed the sample, now the code needs to be edited.

    Try it now.
    There are still more pictures in group 3 sheet 1 compared to group3 sheet2
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Thanks Dave - I appreciate it. I thought I could just adjust the code to suit but obviously not the case.

    The scores on my sheet are from a VLOOKUP. Just wondering whether these would cause an issue? I don't know why but getting a run-time error on the GetPics routine but everything is the same on my master sheet and the only thing I can think of is the VLOOKUP generated scores.

    Screen shots attached.

    Thanks for all your help and time.
    Attached Files Attached Files

  17. #17
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    Are you using the same codes in the previous attachment?

  18. #18
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    yes............

  19. #19
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    I can't tell, you attached a word doc with pictures?

  20. #20
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    I couldn't upload pictures for some reason so put them in a word doc for you to see. I was hoping it was something straightforward. Just wanted to know if any formulaes in the 'scores' columns would affect the 'GetPics' sub routine? It seems to trip over on 'nm.Delete' (with the nm As Name variable)

  21. #21
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    I don't know, you haven't supplied the wb that causes that error.

  22. #22
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Dave - for now I have commented out the piece of code

    Please Login or Register  to view this content.
    and it seems to work.

    When I stripped down my master template, I could leave the code above in and it would work. But on the master template itself (with all the other tabs etc), I would get the error. So I suspect it's something else on the sheet it is not liking.

    So for now will work without the above code. Could you let me know if it is essential / desirable and should be in there?

  23. #23
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    It just removes the named ranges the pictures are going to go into, then the code names the ranges again, this was to make sure there are no mismatched range names to picture names.

  24. #24
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Ok thanks for clarifying that. I will have to be careful with the ranges for now until I work out why the syntax error is occurring.

    Thanks for all your help - much appreciated.

  25. #25
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Dave - quick question. What is the best way to do the following:

    Once the pics are copied across to sheet2, I need to vlookup some data based on the pic in cell x (for that candidate). Is it possible to do a vlookup using the pic itself as the reference point?


    I'm thinking 2 options:

    1.I could place some data behind the pic in sheet1 (ie. the 4 columned grouped lists) but when the pics are copied across, the data in the cell (behind the pic) is not copied onto sheet2. If it was, then I could just use that (relative) data for e.g. an admission number, to do the vlookup to get hold of other data.
    2.Use the existing pic names themselves e.g. Group1Pic1 and use for. e.g
    Please Login or Register  to view this content.
    function to get the pic filename. Then perhaps do a
    Please Login or Register  to view this content.
    to match the pic filename with the admission number (ie. without .jpg on the filename) to get data from a different tab.

    Hope the above makes sense and would appreciate any guidance here.

    Thanks
    Last edited by technik; 12-04-2019 at 08:28 AM.

  26. #26
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    Make the named ranges in sheet 1 include all the columns, then your copy code can determine what group to include in the vlookup formula.

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

  27. #27
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Thanks Dave!

    I will mark the thread as solved although I have just realised that when resetting the pictures on sheet2, all the data disappears (for e.g. the age, salary, job title etc. etc. of a candidate which I now have from the VLOOKUP). This means I have to manually copy/paste the vlookup formulae for EVERY candidate again. Is there a way around this? Could the reset button only delete the 15 (3x5) small cells for each candiate that sit within the 5x6 range for each candidate (because the other data goes around the pic.)

    If its any help all of the candidate personal information sits in a 'main data' worksheet.

    Thanks once again for everything.
    Last edited by technik; 12-04-2019 at 09:21 AM.

  28. #28
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy paste region to another exact location(s)

    The code makes the formula, why would you need to type it back in?

    This is where the pic range is set

    Set PicRng = Range(Cells(rw, cl), Cells(rw + 5, cl + 2))

    You can change the 5 to a 4

  29. #29
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: Copy paste region to another exact location(s)

    Sorry Dave - I have probably haven't explained myself well enough.

    If you look at the attached sheet, hopefully you'll see what I mean. There would be VLOOKUP formulas going either side of the photo, the attached shows a few examples (dummy data) only though.

    Not sure when copying the pics across to sheet2, the code-loop can also extract/copy/paste other data from the 'main data' tab at the same time? This way if all the data is deleted on reset it doesn't matter as easily retrieved when running 'get pics' routine?

    As ever, thanks for your help.
    Attached Files Attached Files
    Last edited by technik; 12-04-2019 at 01:03 PM.

+ 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. Current Region Copy Paste
    By Dbeethekidd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2015, 07:38 AM
  2. Copy and paste between two work books paste into unspecified location
    By jessica88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2014, 07:28 AM
  3. exact copy and paste
    By jgross in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-01-2013, 03:11 PM
  4. VBA Copy-paste values with changing paste location
    By booost in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2012, 10:39 AM
  5. VBscript to copy paste chart in exact location in other sheet
    By Gurushankar in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-13-2011, 01:45 PM
  6. Seach, Copy, select paste location, paste using macros
    By helpdave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2010, 11:36 PM
  7. exact copy/paste
    By jmwismer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-20-2005, 11:05 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