+ Reply to Thread
Results 1 to 10 of 10

Delete to last row based on found cell value using find function

  1. #1
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Delete to last row based on found cell value using find function

    I have some code that tests to find a variable within a range. The problem is my data sets can be over 100,000 rows so looping is very inefficient. I do have a find script, but I am stumped on how to use the cell.address combined with lastrow to delete rows from the found value to last row. Below is the loop that shows what I want for a result
    Please Login or Register  to view this content.
    Here is my pseudocode of the find sub:
    Please Login or Register  to view this content.
    I can use select and delete, but I would like to know how to do this using just the variables.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Delete to last row based on found cell value using find function

    Try:
    Please Login or Register  to view this content.
    The macro assumes that land is a variable.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: Delete to last row based on found cell value using find function

    That's correct; however, it's deleting all cells above land. I would need all cells below land.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Delete to last row based on found cell value using find function

    Try:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: Delete to last row based on found cell value using find function

    I did try that but same result, except it takes the column headers with it. I don't get it. It certainly looks to me that found to last row should be deleted, but the results are the first row and found row.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Delete to last row based on found cell value using find function

    Can you attach a copy of your file including any macros you are using?

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,029

    Re: Delete to last row based on found cell value using find function

    What happens if you use this mod to Mumps1 code
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: Delete to last row based on found cell value using find function

    Very strange. There must have been something else in there I wasn't seeing. After cleaning up it seems to work now. Thanks!

  9. #9
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: Delete to last row based on found cell value using find function

    Rows.Count works too! Thanks.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Delete to last row based on found cell value using find function

    Glad it worked out.

+ 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. Find and delete entire rows based on a cell content
    By axtryo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2017, 12:51 AM
  2. vba help to find cell based and delete rows
    By mike760534211 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-30-2014, 09:47 AM
  3. Find, select & delete/move on if not found
    By wishbonenick in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2014, 06:52 PM
  4. Replies: 3
    Last Post: 03-04-2014, 04:55 AM
  5. [SOLVED] Find rows to delete with a macro based on cell content
    By mkraffert in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-28-2013, 06:27 PM
  6. Delete Row based on record found in cell
    By capnhud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2012, 09:04 AM
  7. Find cell based on formula result and delete contents
    By Big Chris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2006, 10:07 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