+ Reply to Thread
Results 1 to 5 of 5

Limit number of rows pasted with pastespecial

  1. #1
    Registered User
    Join Date
    11-03-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2010
    Posts
    65

    Limit number of rows pasted with pastespecial

    Hello - I have one spreadsheet (1000 rows, 30 columns) where users filter down the data until they have the set of students_ids (Column A) that they want to work with.

    Then they click a button which runs the code below to copy the student_id's from the current spreadsheet to another spreadsheet (Test Transfer Data.xls).

    What I would like to do is modify the code to only paste the first 10 id's. So the maximum it will ever paste is 10 ids (even if they filter down to 100 rows) Similar to a select top 15.......

    Thank in advance!!

    Please Login or Register  to view this content.

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

    Re: Limit number of rows pasted with pastespecial

    I may be missing something but if your range always start at A5 and you only want 10 values copied why dont you just set the range A5:A15? Maybe I am missing something though.

  3. #3
    Registered User
    Join Date
    11-03-2010
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Limit number of rows pasted with pastespecial

    Sorry for the confusion.
    The sheet is filtered so the original sheet contains 1000 rows but is filtered down to 20 rows (the other 1980 are hidden).

    The paste correctly only pastes the 20 visible rows but I want to only select the first 15.

    So I have to list A1:A1000 (because the filter might be looking at rows 10, 15, 150, 755, 756, 950, etc.) but cannot figure out how to limit the results to 10 rows.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Limit number of rows pasted with pastespecial

    There is a way to loop through filtered data, could you supply a sample workbook.......

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

    Re: Limit number of rows pasted with pastespecial

    I think this should work for you. The i used SpecialCells to select all the filtered values ie all the visible ones. I was thinking that you could just remove them after they are copied over to the new sheet. Depending on how the new sheet is set up this may cause some conflicts but seeing as how you wrote the macro initially i am sure you can adjust tailor it to fit your needs.

    Please Login or Register  to view this content.

+ 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