In "T neu" are partially updated prices, which are assigned to serial numbers (these are not necessarily numerical). The updated prices should be inserted in the appropriate line in "T alt". The column headers are always the same in the two tables, but there are not the same number of columns (also the order is not necessarily the same in the tables). The serial numbers are uniquely assignable.
In "T neu" mostly not all serial numbers are available and sometimes there is no or the same price stored. In these two cases, the price should not be updated.
If the price is updated, it should be coloured yellow.
I've got a VBA script where I do not get any further. Maybe you could help me making it more "intelligent".
Find my test document here: Test document
In "T neu" mostly not all serial numbers are available and sometimes there is no or the same price stored. In these two cases, the price should not be updated.
If the price is updated, it should be coloured yellow.
I've got a VBA script where I do not get any further. Maybe you could help me making it more "intelligent".
VBA Code:
Sub tt()
On Error GoTo Fehler
Dim TB1 As Worksheet, TB2 As Worksheet, i As Integer, j As Integer
Dim Sp1 As Integer, Z1 As Integer, LR As Integer, LC As Integer, Spalte As Integer
Const APPNAME = "TT"
Application.ScreenUpdating = False
Set TB1 = Sheets("T alt")
Set TB2 = Sheets("T neu")
Sp1 = 1
Z1 = 1
LC = TB2.Cells(Z1, TB2.Columns.Count).End(xlToLeft).Column
For i = Sp1 To LC
Spalte = WorksheetFunction.CountIf(TB1.Rows(Z1), TB2.Cells(Z1, i))
If Spalte > 0 Then
Spalte = WorksheetFunction.Match(TB2.Cells(Z1, i), TB1.Rows(Z1), 0)
LR = TB2.Cells(TB2.Rows.Count, 1).End(xlUp).Row
For j = Z1 To LR
With TB1.Cells(j, Spalte)
If .Value <> TB2.Cells(j, i) Then
.Value = TB2.Cells(j, i)
With .Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
End With
Next j
End If
Next i
Err.Clear
Fehler:
Application.EnableEvents = True
If Err.Number <> 0 Then MsgBox "Fehler in Sub """ & APPNAME & """" & vbCrLf _
& "Fehlernummer: " & Err.Number & vbLf & Err.Description: Err.Clear
End Sub
Find my test document here: Test document