Forum Discussion

hrh_dash's avatar
hrh_dash
Iron Contributor
Oct 14, 2022
Solved

Find all specific text and copy into another sheet using a do until loop

How can amend the code below to copy text at specific cells if there are more than one find.   For example, if there are 3 Finds of "OWNER" and therefore i would want all the data pertaining to "OW...
  • HansVogelaar's avatar
    Oct 14, 2022

    hrh_dash 

    By the way, I'd do the loop like this, it's slightly more efficient.

            Do
                lastRow = lastRow + 1
                ws_N.Range("B" & lastRow).Value = rng.Offset(0, -1).Value
                ws_N.Range("A" & lastRow).Value = rng.Offset(0, -2).Value
               
                Set rng = ws.UsedRange.FindNext(rng)
                If rng Is Nothing Then Exit Sub
            Loop Until rng.Address = adr

Resources