Combine different cell content searches with equal outcome

Deverti

Board Regular
Joined
Sep 5, 2020
Messages
63
Office Version
  1. 365
Platform
  1. Windows
Im using this to search for content and clear the corresponding row.
I need to use it for several different cell contents, not only the two i listed here and it s becoming chaotic.

Is it possible to simply combine them?

Would be amazing if there s a way to just list them somewhat like this: If rng.Item(i).Value = "AUFWAND" or "GESAMT-TOTAL AUFWAND" or "" Then

VBA Code:
Sub ClearRow_AUFWAND()
    Dim rng As Range
    Set rng = ActiveSheet.UsedRange
    
    For i = rng.Cells.Count To 1 Step -1
        If rng.Item(i).Value = "AUFWAND" Then
            rng.Item(i).EntireRow.Clear
        End If
    Next i
End Sub

Sub ClearRow_GESAMT_TOTAL_AUFWAND()
    Dim rng As Range
    Set rng = ActiveSheet.UsedRange
    
    For i = rng.Cells.Count To 1 Step -1
        If rng.Item(i).Value = "GESAMT-TOTAL AUFWAND" Then
            rng.Item(i).EntireRow.Clear
        End If
    Next i
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Will those values be in a particular column, or can they be anywhere?
 
Upvote 0
Ok, how about
VBA Code:
Sub Deverti()
   Dim Cl As Range
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      Select Case Cl.Value
         Case "AUFAND", "GESAMT-TOTAL AUFWAND"
            Cl.EntireRow.Clear
      End Select
   Next Cl
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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