Consulting

Results 1 to 9 of 9

Thread: Delete Rows In A Sheet

  1. #1

    Delete Rows In A Sheet

    Hello All,

    I have made a macro which auto - filters on certain criteria and copies the data to another sheet.

    Now for example after filtering i am left with 10 rows it will copy those 10 rows and paste to another sheet which might have more than 10 rows.

    So i want a macro which will delete all rows after 10 rows.

    i already have a count of filtered rows available.

    Regards,

    Tejas Dave

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What are you trying to delete, the 10 rows copied, the rows in the target sheet, the source sheet, or what? Before you copy, after you copy?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    I am trying to delete all rows execpt the 10 which were copied and pasted.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then why not just delete the source worksheet? If you need that data twice, copy the filtered data to a new worksheet as well and delete the original.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    I cannot as the source sheet has formula's and links in it.i am pasting to a specific range starting from cell B2.

    I already have a code which tells me the number of rows that were copied.is it possible to get a code which removes all rows except for that number of rows i.e 10 rows.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I can't see why the formulas of the required rows would not be retained?

    But assuming we don't, I would still address it from the other side. Filter the data by your criteria, copy the filtered rows. Then re-filter by NOT your criteria, and delete the filtered rows.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    here is what i do :

    * Filter my criteria.
    * copy the remaining data
    * paste to another sheet to a specific range. ( the sheet will always have old data in it)

    now after i paste the data to another sheet i want to delete all rows except the ones i pasted.

    Kindly assist.

    Regards,

    Tejas Dave

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Did you read post #6?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    yes i did thats what i am trying to explain why i cannot use that approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •