+ Reply to Thread
Results 1 to 4 of 4

Function to split up a table based upon the values in a reference column

  1. #1
    Registered User
    Join Date
    06-08-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    2

    Function to split up a table based upon the values in a reference column

    Hi guys I'm very new to VBA so this is probably a basic question

    I am trying to make a function that selects a range of cells where the range size is determined by the value of the left most column's cell.

    So for example in a specific sheet I want to select all the rows where "1" appears in column A cells and then copy those rows into a specific sheet and similarly for other numbered cases.

    Any ideas?

  2. #2
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Function to split up a table based upon the values in a reference column

    Post a sample workbook.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  3. #3
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Function to split up a table based upon the values in a reference column

    Hello there,

    Below is a macro that provides an inputbox for you to enter the value you wish to search for in column A and then finds all instances of that value and copies its entire row and pastes it into a worksheet entitled "Sheet2".

    To use this code press Alt and F8 at the same time on your keyboard. Then enter the text InputValue in the macro name box. Clear the contents if there is anything in there and then enter the text InputValue.

    The select create. In between the Sub InputValue and End Sub paste the below code. Anything that appears in green is a comment I left to help you understand what the code was doing.

    Right now the macro assumes your worksheet names are Sheet1 (copy from worksheet) and Sheet2 (copy to worksheet). Look through the code below and change the names of the worksheets to the names of your worksheets before running to ensure it works correctly.


    Please Login or Register  to view this content.
    To run the code press Alt F8 again and then select the InputValue Macro and select Run.

    Let me know if this works for you!

    Thanks!

  4. #4
    Registered User
    Join Date
    06-08-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Function to split up a table based upon the values in a reference column

    This is exactly what I wanted! Thanks so much

    I'm going to modify it and repost this weekend if anyone is interested in using it. What its meant to do is break up an entire worksheet into its constituent parts based upon the values of a left-most column and then copy those cells into specific sheets corresponding to the values in the left hand column.

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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