+ Reply to Thread
Results 1 to 7 of 7

Search, Copy and Paste selections of a column

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    24

    Question Search, Copy and Paste selections of a column

    Hey,
    I'm trying to write a macro with a button in the workbook that has the headings of all my column (which are in row 5) in a drop down menu. When a heading is selected I would like the macro to go the column with that heading and copy a selection below. The various columns are spread of multiple sheets.

    So for example:

    Apples Bananas Pears
    1_________2______3
    1_________2______3
    1_________2______3

    I would like a button with the options (Apples, Bananas, Pears), after selecting Bananas I would like it to copy and paste the column into column x.
    Edit: I have also attached an example workbook.

    Thanks.
    Attached Files Attached Files
    Last edited by Adamcadaver; 09-20-2010 at 09:38 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Search, Copy and Paste selections of a column

    Not sure if you mean a macro or data validation list...

    Probably data validation...

    Start by naming each columnar range.. so select one columnar range and type the name you want to appear in the dropdown (the column headings) into the empty field to the left of the formula bar (i.e. into the Name Box)... do the same for each.

    The go to the cell you want the dropdown box in, and go to data|validation and select List from the Allow menu and then in the source field enter the range of headers of the columns.

    Then click Ok.

    Then in cell under the data validation, enter formula:

    =IF(ROWS($A$1:$A1)>COUNTA(INDIRECT(A$1))-1,"",INDEX(INDIRECT(A$1),ROWS($A$1:$A2)))

    and copy down as far as you want.

    Now when you select a new item, it should autoupdate your results.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    09-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Search, Copy and Paste selections of a column

    I'm not sure if I have described myself well enough, in the actual workbook there are >800 columns so I'm not sure if naming each is the way to go, however, I'm giving the way you said a try now on a sample and seeing how it works..

  4. #4
    Registered User
    Join Date
    09-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Search, Copy and Paste selections of a column

    Ok I have made the drop down menu and filled the space below with you formula but the cells don't have an value in them, what am i doing wrong?

    Edit: got the values but not everything is correct, so I'm currently tweaking...
    Last edited by Adamcadaver; 09-20-2010 at 11:19 AM.

  5. #5
    Registered User
    Join Date
    09-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Search, Copy and Paste selections of a column

    I don't think the data validation route is going to work, I need to use the full names of each column and they are not all valid entries in the name box.Also, the blank squares are being replaced by 0 which will skew the data analysis I would like to do in the new area.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Search, Copy and Paste selections of a column

    I have been in meetings all morning here... and am going to be busy this afternoon too.. so not sure how much time I can spend.

    Your named ranges must not have spaces in them, they could have underscores...

    Then you would have to create a separate list somewhere of all the possible column names to include in your dropdown menu.

    Then you would substitute the formula above with:
    Please Login or Register  to view this content.
    This will substitute the name chosen in your dropdown with a version of the name with underscores instead of spaces and they should match a column name to search into.

    If done correctly, the blanks should return as blanks and not 0's.

    Once you attempted this, post the sample workbook if it is not working....and I (or someone else) will try to assist... maybe someone has another idea... vba perhaps?

    If the columns were all in one sheet, you would not perhaps need the named ranges... and column name alterations....

  7. #7
    Registered User
    Join Date
    09-16-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Search, Copy and Paste selections of a column

    trying it now

    Edit: I don't seem to be able select cells on different sheets than the data validation.
    Last edited by Adamcadaver; 09-21-2010 at 08:56 AM.

+ 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