+ Reply to Thread
Results 1 to 18 of 18

Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

  1. #1
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    I'm creating a document in excel that needs specific information copied from columns and pasted ntot a specific range. The problem I'm having is that it's copying blanks and duplicate information from the cells and it's putting it outside my range. I would like to remove the blanks and duplicate values and keep all information within my "Panels" range. My "Panels" range is from AZ95:BM104 respectively. Here's the code I currently have.

    Please Login or Register  to view this content.
    Any help is greatly appreciated.
    Last edited by dondada82; 04-15-2017 at 03:51 AM. Reason: Additional information

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Hi dondada82

    In future please view the forum rules before posting. Your post does not comply with rule #3.
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window.
    Try this: Not tested.
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Sintek,

    I apologize for not following the forum rules. I'm new to this and will follow the rules going forward. I modified the coding that you've provided and I'm getting an error. Here's my error.

    Run-time error '1004':
    The information cannot be pasted because the copy area and the paste area are not the same size and shape. Try one of the following:

    Click a single cell and then paste.
    Select a rectangle that is the same size and shape, and then paste.

    Here's how I modified the coding:

    Please Login or Register  to view this content.
    Last edited by dondada82; 04-15-2017 at 03:51 AM.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Hi dondada2

    Please edit your posts to conform to the rules.

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window.

  5. #5
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Sintek,

    Sorry about that. It's a learning curve for me. They've been edited.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    On This line
    Please Login or Register  to view this content.
    ws refers to your active worksheet...What is the name of the worksheet you are sending info to.

  7. #7
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    the name of the worksheet is Folder Generator

    All information is on the same worksheet. There's values from S:AV that needs to be copied and pasted to another section, which I have set a range called Panels. The problem with my original code was that:

    1) the paste went beyond the specified range "Panels". For example it pasted into the Panels range and one column to the right. Then it pasted many blank rows below and outside of the "Panels" range. I would like the information to be contained in the "Panels" range, which is AZ95:BM104 respectively.
    2) It contained duplicated values, which I would like to remove, if possible.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Quote Originally Posted by dondada82 View Post
    Please Login or Register  to view this content.
    Your code is confusing, better upload a small sample workbook with before/after.

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    The selection S2:AV100 you are copying from and AZ95:BM104 pasting to is not same size...Perhaps you should upload a sample workbook so that we can have a look.

  10. #10
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    for some odd reason the attachments link in this forum isn't working.

    This is what I'm trying to do:

    I have a worksheet (Folder Generator) that I created in excel that gets populated from other worksheets within the document. At any given moment when I up the the Folder Generator with new information columns S:AV information can change, but the values within these columns will never be full and many blanks will be portrayed. Some of the values within these column can also be duplicated, which I would like to have it delete all duplicated values (but I need at least one of the duplicated values to stay).

    My original code copied and special pasted values only from S2:AV100 (values will never grow more than that range) into the "Panels" range, which starts at $AZ$95 and ends at $BM$104.

    The copy and paste feature works, but its pasting some of the information outside of the "Panels" range and filling all empty rows with blanks. I know this because I have borders that disappear as soon as I update the values in the "Panels" range.

    I hope my explanation is straight forward and doesn't add more confusion. I do apologize in advance.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    I think some information is still missing about "many blanks", "duplicates" etc and how you want the result.

    to upload a workbook,

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  12. #12
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    The file should be here now. Thanks again for all your help.
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Thanks for the workook.

    I can see many blanks, but no duplicates...

    You have 30 columns 100 rows to copy, S2:AV100, and only 10 rows 14 columns in "Panels" named range.
    How do you want the result?

    Can you upload a sample data and the result clearly showing the logic behind it?

  14. #14
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    If you populate the folder with engine 1 inspection (A2) and hit the update package button, then hit the update panels button (with my original coding) it inputs the information in the "Panels" range as first row 432AT, 432AT, 432AT, etc...... and second row as 443AB, 443AB, 443AB, etc.....

    I would like it to remove the duplicates and just see one set of 432AT and 433AB and no blank cells.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Still not clear to me though...
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Jindon,

    That looks like it's working as it should. Many thanks.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Glad that was what you wanted and thanks for the rep.

    If you want to stop when data to be pasted exceeds the number of cells in "Panels" then add 2 lines.
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-23-2017
    Location
    Windsor Locks, CT
    MS-Off Ver
    2013
    Posts
    38

    Re: Copy & Paste Columns to Specific Range while Removing Blanks & Duplicates

    Jindon,

    Thanks again. I went to get some sleep since it after 6am my time. So everything works perfectly. I filled some of the columns with erroneous data to see if it stayed within the "Panels" range and it did. I'll add the two lines above, although I may never need it. Thanks again!

+ 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 and paste random cells values from a range to another sheet column with no blanks
    By macquhele in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2015, 06:05 PM
  2. Replies: 8
    Last Post: 04-04-2013, 08:02 PM
  3. Copy and paste specific range to date specific range in alternate sheet
    By alanalmarza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 08:29 AM
  4. Replies: 18
    Last Post: 09-08-2012, 07:13 AM
  5. Copy/Paste duplicates from multiple columns
    By sush23 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 08-22-2012, 08:34 PM
  6. [SOLVED] Copy data from two columns and paste without duplicates in another column
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2012, 07:56 PM
  7. Find duplicates in 2 columns and copy/paste to new worksheet
    By davidparkes in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 11-12-2010, 01:38 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