Delete a row containing specific text - working but slow on larger number of records

  • I have the following vba code I picked up on stack overflow sometime back, the macro deletes records where the number 1 is present in column A but once this encounters several hundred rows the speed is very slow can anyone suggest a faster method to achieve the same?



    credits for original macro this was derived from: stackoverflow.com/questions/27927042/find-and-delete-rows-where-cell-value-is-n-a

  • Re: Delete a row containing specific text - working but slow on larger number of reco


    Fastest method I've come up with is doing the following by using filters, this achieves an instant result regardless the number of records not sure if its the nicest way to do it, but its works! This assumes no header row present.


  • Re: Delete a row containing specific text - working but slow on larger number of reco


    Hi ngowanlock,


    Here's another method that uses a helper column which as a result of not looping is very fast:



    Regards,


    Robert

  • Re: Delete a row containing specific text - working but slow on larger number of reco


    An another different way..


    Borrowed one of Jindons lovely lines to build the 1D array.


    You might need to adapt is slightly to suit.. check out the attachment..



    Edit: Just thought about it.. change the line where it dumps the result to sheet to the below so the column count is dynamic.

    Code
    [A1].Resize(UBound(X) + 1, UBound(Z, 2)) = Application.Index(Z, Application.Transpose(Array(X)), Evaluate("Transpose(Row(1:" & UBound(Z, 2) & "))"))

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!