Gruppe
Allgemein
Problem
Die Preise im Tabelle1 sind durch Preise in Tabelle2 zu ersetzen. Wird ein Artikel in Tabelle2 nicht gefunden, ist der Hintergrund zu markieren und umgekehrt.
StandardModule: Modul1
Sub PreisVergleich()
Dim wks As Worksheet
Dim vRow As Variant
Dim iRow As Integer, iRowL As Integer
Set wks = Worksheets("Tabelle2")
iRowL = Cells(Rows.Count, 1).End(xlUp).Row
For iRow = 1 To iRowL
vRow = Application.Match(Cells(iRow, 1).Value, wks.Columns(1), 0)
If IsError(vRow) Then
Cells(iRow, 1).Interior.ColorIndex = 36
Else
Cells(iRow, 2).Value = wks.Cells(vRow, 2).Value
End If
Next iRow
iRowL = wks.Cells(Rows.Count, 1).End(xlUp).Row
For iRow = 1 To iRowL
vRow = Application.Match(wks.Cells(iRow, 1).Value, Columns(1), 0)
If IsError(vRow) Then
wks.Cells(iRow, 1).Interior.ColorIndex = 36
End If
Next iRow
End Sub