Makro auf mehrere Blätter anwenden
Hallo zusammen,
habe folgendes Makro(Auszug), das ich gerne auf mehrere Blätter anwenden möchte. Bisher funktioniert es nur, wenn ich es auf jedes einzelne Blatt anwende. Hier werden Werte aus Spalte I mit denen aus Spalte G verglichen. Steht in Spalte I ein Wert, werden die Zellen F,G,H durchgestrichen.
Hoffe ihr habt Ideen.
Option Explicit
Public Sub vergleichen()
Dim lngI As Long, intWert As Integer
Application.ScreenUpdating = False
For lngI = 1 To Cells(Rows.Count, 1).End(xlUp).Row
intWert = Application.WorksheetFunction. _
CountIf(Worksheets("11.15").Range("I:I"), Cells(lngI, 7).Value)
If intWert > 0 Then
Cells(lngI, 6).Font.Strikethrough = True
Cells(lngI, 7).Font.Strikethrough = True
Cells(lngI, 8).Font.Strikethrough = True
End If
Next lngI
For lngI = 1 To Cells(Rows.Count, 1).End(xlUp).Row
intWert = Application.WorksheetFunction. _
CountIf(Worksheets("11.35").Range("I:I"), Cells(lngI, 7).Value)
If intWert > 0 Then
Cells(lngI, 6).Font.Strikethrough = True
Cells(lngI, 7).Font.Strikethrough = True
Cells(lngI, 8).Font.Strikethrough = True
End If
Next lngI
Application.ScreenUpdating = True
End Sub
Antwort schreiben
Antwort 21 von Martin123 vom 10.09.2020, 09:47 Options
Hallo Rainer,
habe deinen Code aus 9 mit Änderungen aus 10 in ein allgemeines Modul eingefügt und es funktioniert soweit. Mit der Änderung in Antwort 19 habe ich es nicht zum Laufen gebracht.
Danke für die Hilfe.
Gruß martin
Antwort 22 von rainberg vom 10.09.2020, 11:50 Options
Hallo Martin,
das Makro ist in Deiner Datei getestet und läuft.
Wenn es bei Dir nicht läuft, hast Du nicht beachtet, was ich Dir geschrieben habe.
Gruß
Rainer
Antwort 23 von Martin123 vom 10.09.2020, 12:19 Options
Hallo Rainer,
meinte damit eigentlich, dass alles so ist wie es sein soll. Die Datei komplett abgedeckt.
Gruß
Martin