+ Reply to Thread
Results 1 to 7 of 7

VBA Copy a Varying Number of Whole Rows

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    Boston, MA
    MS-Off Ver
    Excel 2008
    Posts
    4

    VBA Copy a Varying Number of Whole Rows

    I have a workbook that will have information about different users and am trying to copy the top users in different categories to another sheet.

    Right now, I have my macro set to go into the worksheet and sort the workbook based on the criteria I am interested in. I have the number of "top users" on a different sheet, and I want to be able to select the number of rows that corresponds to the number of top users, copy it, and paste it into another sheet.

    For example, one of the categories is Questions Asked. For a specific date, there were 49 top question askers (this value is given in cell F31 on the sheet "Question Distribution"). In the sheet where all the data is, "Daily Activity," I have the macro sort the question category, and then I want to select the top 49 rows, copy the information in those rows, and paste them to a new sheet "Top Questions". But should the value in cell F31 change, I want it to select that many rows instead.

    Is this possible?

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Copy a Varying Number of Whole Rows

    Submit a copy of your workbook.

  3. #3
    Registered User
    Join Date
    06-21-2014
    Location
    Boston, MA
    MS-Off Ver
    Excel 2008
    Posts
    4

    Re: VBA Copy a Varying Number of Whole Rows

    As it contains sensitive information, I cannot. I'll see if I can put together a similar one. But isn't it possible to answer this without the actual workbook?

    I'm basically looking to select a number of rows [such as with rows("2:50").select ] except instead of the range being 2:50, it being 2: (the value given in cell F31 on a different worksheet).

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Copy a Varying Number of Whole Rows

    Possible to answer? Yes. Do I want to take the time to create a worksheet matching all the parameters you put in place so I can test the code to make sure it works? No.

  5. #5
    Registered User
    Join Date
    06-21-2014
    Location
    Boston, MA
    MS-Off Ver
    Excel 2008
    Posts
    4

    Re: VBA Copy a Varying Number of Whole Rows

    So with this sample workbook, I want to be able to have the macro go to the Activity sheet, sort descending by questions, and then select rows 2:The value given by cell D3 in the Top Users sheet and then paste those rows to the Top Questions sheet.

    Similarly, I will want it to sort descending by answers, select rows 2:The value given by cell D4 in the Top users sheet, and paste those into the Top Answers sheet.

    Etc etc
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Copy a Varying Number of Whole Rows

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-21-2014
    Location
    Boston, MA
    MS-Off Ver
    Excel 2008
    Posts
    4

    Re: VBA Copy a Varying Number of Whole Rows

    Seems to work great! Thanks so much. The range("D3").value command is the command I was really looking for. Pretty neat stuff

+ 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] Macro to copy three cells to varying number of rows
    By socalobie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-20-2014, 12:45 AM
  2. [SOLVED] How to get a subtotal from a varying number of rows?
    By Mark53 in forum Excel General
    Replies: 4
    Last Post: 08-04-2013, 02:12 PM
  3. Replies: 3
    Last Post: 03-27-2013, 03:58 PM
  4. How To Deal With Varying Number of Rows
    By messnj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2007, 02:40 AM
  5. Sum varying number of rows
    By LSkarbek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2006, 11:10 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