+ Reply to Thread
Results 1 to 4 of 4

Looping Find

Hybrid View

  1. #1
    Registered User
    Join Date
    06-19-2007
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    72

    Looping Find

    Hi everyone

    Hopefully this is just a quick one.

    I currently have this code searching for "--------" and deleting the entire row once it has found it.

    Columns("A:A").Find(What:="--------", After:=ActiveCell, LookIn:=xlFormulas, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Activate
            Selection.EntireRow.Delete
    I would like to loop this so that it finds all instances of "--------" and deletes each row that it is found on then stops once all "--------" have been found and deleted.

    If anyone can point me in the right direction, it would be greatly appreciated.

    Thanks

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Also should

    xlformulas be changed to Values and
    xlPart to Xlwhole

    Dim Fnd As Range
    Do
        Set Fnd = Columns("A:A").Find(What:="--------", After:=Range("A1"), _
        LookIn:=xlFormulas, LookAt:=xlPart)
                   
        If Fnd Is Nothing Then
            Exit Do
        Else
            Fnd.EntireRow.Delete
        End If
    Loop
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor beeawwb's Avatar
    Join Date
    01-04-2004
    Location
    Perth, WA, Australia
    MS-Off Ver
    Microsoft Office Excel 2003 (11.8146.8221) SP2
    Posts
    105
    Edit: Never mind, solution done above.

    -Bob
    Last edited by beeawwb; 06-05-2008 at 02:48 AM. Reason: Solution posted, mine didn't work.

  4. #4
    Registered User
    Join Date
    06-19-2007
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    72
    Great

    Thankyou very much - works perfectly

+ 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. [SOLVED] match 3 hold digits
    By stewart08 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-13-2008, 03:30 PM
  2. Programming a Find Loop?
    By mcbain in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2008, 04:44 AM
  3. find, meet condition, sum range, deduce, find next
    By pinstripe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-27-2007, 09:30 AM
  4. Using find function to find entries in multiple cells
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2007, 08:45 PM
  5. FIND / SEARCH find nonnumeric
    By Barry Staples in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-03-2006, 06:34 PM

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