+ Reply to Thread
Results 1 to 3 of 3

Condensing Find Code

Hybrid View

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

    Condensing Find Code

    Hi Everyone

    Is there a way to simplify the following code?

    Cells.Find(What:="Selection", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
        Cells.Find(What:="Site:", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
        Range("A15782").Select
        Cells.Find(What:="Item:", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
        Cells.Find(What:="Buyer:", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
        Cells.Find(What:="Prod.Line:", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
        Cells.Find(What:="Supplier:", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
            Cells.Find(What:="Purch/Manuf:", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Selection.EntireRow.Delete
    I am in the process of learning VBA and I'm not too sure what can be deleted without upseting the code.

    Thanks

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    On Error Resume Next
    For Each e In Array("Selection", "Site:", "Item:", "Buyer:", "Prod.Line:", _
               "Supplier:", "Purch/Manuf:")
        Cells.Find(e,,,xlPart).EntireRow.Delete
    Next

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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