+ Reply to Thread
Results 1 to 18 of 18

Unique Values, Paste and Transpose

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Unique Values, Paste and Transpose

    Hi,

    I have a sheet which contains a large amount of data on it ("data") which lists customers in no particular order.

    Is there any quick way in which I can have a code which automatically detects only unique customers and then once found it pastes them to a new sheet (called overview).

    I have included an example of what I am trying to achieve as I can never explain myself too well.

    If possible i would need it pasted to the overview sheet, cell I3 if possible?

    Any questions please ask, thank you in advance to anyone that has time to look into this.

    Paul
    Attached Files Attached Files
    Last edited by pauldaddyadams; 11-09-2011 at 04:23 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Use the advanced filter (in the Data tab on top) to filter and create a list of unique customer numbers. Then copy that list and PasteSpecial to the location on your new sheet. Choose transpose to get the data going horizontal like you want it to. You can pull in the customer names with a lookup function.

    If you really need this automated, try using the macro recorder while you do the above process.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    Is there any way to do it without an advanced filter? The reason being is that I have alot of these to do it for and i want it to be as quick as possible

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    You can use array formulas to pull out unique values, but I strongly suspect it will run much slower than the advanced filter. The filter usually doesn't take too long, and if you automate it, the process should go fairly quick.

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    Do you know how to automate an advanced filter?

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Have you tried the Macro Recorder as I suggested above?

  7. #7
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    Hi, i tried and failed!

    I am going to try a automated excel fiter but ill post that in a seperate thread

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Could you explain what you mean when you say you failed?

  9. #9
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    Thanks for showing an interest!

    Just establishing an inital unique list, I keep getting Customer 1 appearing twice (i will attach a dump of the settings)

    Am i doing something wrong?

  10. #10
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Excel often assumes your first cell is a header. Be sure you are selecting a header with your data when you do the advanced filter.

  11. #11
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    ok - I managed to get a list of unique entries however when when I copy the range this will change each time I do it. I have tried to copy the column however I get an error when I paste special this.

  12. #12
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    In your code, you will need to define a variable that will hold the number of values in the column. In general, you can find the last row containing values in a column with this line of code:

    Please Login or Register  to view this content.
    where "A" is the column.

    If you post the code that the macro recorder gave you, I can help you tweak it to work for variable columns of data.

  13. #13
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    This is the macro which nearly works

    Please Login or Register  to view this content.
    Currently it pastes the filtered list on whichever sheet I am working on, how do I get it to select the "macro" sheet and then to paste to cell A1?

    Regarding your code, do i replace my code:
    Please Login or Register  to view this content.
    with this?:
    Please Login or Register  to view this content.

  14. #14
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Ok, there are some ways we can potentially clean up that code to make it more efficient (in general, selecting cells/sheets is unnecessary when working in code), but first let's get it to work the way you want it. My first guess would be this:

    Please Login or Register  to view this content.
    I've changed the line that selects your filtered list to always go down to the last row with data (as we previously discussed), I put the destination sheet as "macro" like you said, and I changed the destination cell to A1. Does it work as you'd like it to?

  15. #15
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    I have a problem with the code :


    "Run Time Error 1004

    The infomration cannot be pasted because the copy area and paste area are not the same size and shape"

    Do you know of a fix?
    Last edited by pauldaddyadams; 11-09-2011 at 03:53 PM.

  16. #16
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Any way you can post a sample workbook?

  17. #17
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Unique Values, Paste and Transpose

    Try this, it specifies some of the code that refers to active objects. It also gets rid of some of the selecting:

    Please Login or Register  to view this content.

  18. #18
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Unique Values, Paste and Transpose

    I manged to get it to work, changed only a couple of names:

    Please Login or Register  to view this content.
    Thank you for looking into this!!!! Thats one problem off my list, others here http://www.excelforum.com/excel-work...ed-filter.html
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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