Habe einen Code via Google gefunden den Ich gern nutzen möchte.
Zum Code Selbst:
- Über eine InputBox wird ein "Wert" im Tabellenblatt gesucht
- Lösche ganze Zeile
Hier das Original Makro:
Option Explicit
Const Titel = "Zeilen Löschen mit Wert"
Const Msg = "Wert, nachdem gesucht und gelöscht werden soll."
Sub DelFoundLines()
Workbooks("HM2030_RO_").Worksheets("RO").Activate
Dim i As Long ' Zeilenzähler
Dim tofind As Variant ' Hiernach wird gesucht
Dim found As Range ' Eine Fundstelle oder Nothing
tofind = InputBox(prompt:=Msg, Title:=Titel)
If tofind = "" Then Exit Sub
Application.ScreenUpdating = False
For i = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row _
To 1 Step -1
Set found = Rows(i).Find(what:=tofind, _
LookIn:=xlValues, lookat:=xlWhole)
If Not found Is Nothing Then Rows(i).Delete
Next
Application.ScreenUpdating = True
End Sub
' Quelle: https://www.online-excel.de/excel/singsel_vba.php?f=30
Mit kleinen Änderungen Klapt es teilweise:
Sub DelFoundLines()
Workbooks("HM2030_RO_").Worksheets("RO").Activate
Dim i As Long ' Zeilenzähler
Dim tofind As Variant ' Hiernach wird gesucht
Dim found As Range ' Eine Fundstelle oder Nothing
tofind = UF2_ID_Auslagern.CB_ID_RO
If tofind = "" Then Exit Sub
Application.ScreenUpdating = False
For i = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row _
To 1 Step -1
Set found = Rows(i).Find(what:=tofind, _
LookIn:=xlValues, lookat:=xlWhole)
If Not found Is Nothing Then Rows(i).ClearContents
Next
Application.ScreenUpdating = True
End Sub
Wie kann Ich das Makro so abändern das statt die ganze Zeile Gelöscht wird nur Bestimmte Spalten.Bsp:
- Suche "Wert" in Spalte "C:C" > Auswahl des "Wertes" über die ComboBox "CB_ID_RO"
- Lösche im Bereich ("D:BP") alle Zellinhalte (ohne Formatierung) in der jeweiligen Zeile
Gruß Charly