macro for deleting entire lines if a row has no text /certain text

Tonyk1051

Board Regular
Joined
Feb 1, 2021
Messages
132
Office Version
  1. 2019
Platform
  1. Windows
Hi,


I found a basic macro from here that works below for steps 1 and 2 but i need to know what the code should look like when applying steps 3 through 5 (i tried tinkering around but got nothing) any help is appreciated

1.if column L is greater than 1 delete the line
2.if column F has Y delete the line
3.if column I has borle,haroldh,llavner,jlinares,ephriamw,mordi,moshw,rheins,toviag,jvelez,josfrcs delete the line
4.if column C has any text at all delete the line
5.if column B has any of the names listed below delete the line

OPTOMA
LEICA
MATIAS CORPORATION
DRACO
ROLAND SYSTEMS GROUP U.S.
Hal Leonard
ASUS COMPUTER INT'L
SHENZHEN LEQI NETWORK TECH.
YAMAHA CORPORATION OF AMERICA
SHURE INCORPORATED
HONG KONG YONG NUO PHOTOGRAPHI
PENGO TECHNOLGOY CO. LTD.
SEAGATE TECHNOLOGY, LLC
WESTERN DIGITAL
HAL LEONARD CORP,
TECH DATA CORP.
INGRAM MICRO
D & H DISTRIBUTING CO.
1 SOURCE VIDEO.
HITACHI GLOBAL STORAGE TECH.
BBQ TRADING LLC
JEG & SONS INC.
AMAZON.COM AUCTIONS
ADI
ACER AMERICA, INC
BOSE CORPORATION
ASI COMPUTER TECHNOLOGIES INC.
AUDIOENGINE, LTD.
PROMPTERPEOPLE
COREL
HIKVISION USA INC / REPAIR CEN
ORANGEMONKIE INC
SONOS INC




Code:
 Sub test()
With ActiveSheet
    .AutoFilterMode = False
    With Range("L1", Range("L" & Rows.Count).End(xlUp))
        .AutoFilter 1, ">1"
        On Error Resume Next
        .Offset(1).SpecialCells(12).EntireRow.Delete
    End With
    .AutoFilterMode = False
End With
End Sub
 
Still no direct answer about "LEICA BELL" but give this a try with a copy of your workbook.

VBA Code:
Sub Del_Rows()
  Dim a As Variant, b As Variant, aRws As Variant, CoNames As Variant
  Dim nc As Long, i As Long, k As Long
  Dim bDel As Boolean
 
  CoNames = Split("OPTOMA|LEICA|MATIAS CORPORATION|DRACO|ROLAND SYSTEMS GROUP U.S.|Hal Leonard|ASUS COMPUTER INT'L|SHENZHEN LEQI NETWORK TECH.|" _
                & "YAMAHA CORPORATION OF AMERICA|SHURE INCORPORATED|HONG KONG YONG NUO PHOTOGRAPHI|PENGO TECHNOLGOY CO. LTD.|SEAGATE TECHNOLOGY, LLC|" _
                & "WESTERN DIGITAL|HAL LEONARD CORP,|TECH DATA CORP.|INGRAM MICRO|D & H DISTRIBUTING CO.|1 SOURCE VIDEO.|HITACHI GLOBAL STORAGE TECH.|" _
                & "BBQ TRADING LLC|JEG & SONS INC.|AMAZON.COM AUCTIONS|ADI|ACER AMERICA, INC|BOSE CORPORATION|ASI COMPUTER TECHNOLOGIES INC.|" _
                & "AUDIOENGINE, LTD.|PROMPTERPEOPLE|COREL|HIKVISION USA INC / REPAIR CEN|ORANGEMONKIE INC|SONOS INC", "|")
 
  With Sheets("RO Level Summary")
    nc = Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
    aRws = Evaluate("row(2:" & .Range("B" & Rows.Count).End(xlUp).Row & ")")
    a = Application.Index(.Cells, aRws, Array(2, 3, 6, 9, 12))
    ReDim b(1 To UBound(a), 1 To 1)
    For i = 1 To UBound(a)
      bDel = False
      Select Case True
        Case a(i, 5) > 1: bDel = True
        Case a(i, 3) = "Y": bDel = True
        Case InStr(1, ",borle,haroldh,llavner,jlinares,ephriamw,mordi,moshw,rheins,toviag,jvelez,josfrcs,", "," & a(i, 4) & ",", vbTextCompare) > 0: bDel = True
        Case Len(a(i, 2)) > 0: bDel = True
        Case IsNumeric(Application.Match(a(i, 1), CoNames, 0))
          bDel = True
      End Select
      If bDel Then
        k = k + 1
        b(i, 1) = 1
      End If
    Next i
    If k > 0 Then
      Application.ScreenUpdating = False
      With Range("A2").Resize(UBound(a), nc)
        .Columns(nc).Value = b
        .Sort Key1:=.Columns(nc), Order1:=xlAscending, Header:=xlNo
        .Resize(k).EntireRow.Delete
      End With
      Application.ScreenUpdating = True
    End If
  End With
End Sub
Hey it works perfect, thank you so much
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,216,110
Messages
6,128,896
Members
449,477
Latest member
panjongshing

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top