Bijgaand script werkt goed
nu wil ik daar aan toevoegen dat hij ook kolom A vergelijkt (rijen tussen 2 lege rijen = 1 rit)
als alle getallen in kolom A binnen 1 rit gelijk zijn dan niks doen
als er een verschil is dan hele rit rood maken.
ik heb een foto toegevoegd om dit te verduidelijken.
nu wil ik daar aan toevoegen dat hij ook kolom A vergelijkt (rijen tussen 2 lege rijen = 1 rit)
als alle getallen in kolom A binnen 1 rit gelijk zijn dan niks doen
als er een verschil is dan hele rit rood maken.
ik heb een foto toegevoegd om dit te verduidelijken.
Code:
Sub sorteren_planning()
' Sneltoets: Ctrl+p
ActiveWorkbook.Connections("Query - maxeda_VRT").OLEDBConnection.BackgroundQuery = False
ActiveWorkbook.Connections("Query - maxeda_VRT").Refresh
'Sorteren - uitlijnen
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("VRT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("VRT").Sort.SortFields.Add2 Key:=Range("D2:D111"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("VRT").Sort.SortFields.Add2 Key:=Range("E2:E111"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("VRT").Sort
.SetRange Range("A1:W111")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Worksheets("VRT").Activate
Cells.Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
'Lege rijen invoegen
Worksheets("VRT").Activate
Cells.Select
Set bereik = Range("A2")
rij = bereik.Row
kolom = bereik.Column
Do
If Cells(rij + 1, kolom) <> Cells(rij, kolom) Then
Cells(rij + 1, kolom).EntireRow.Insert shift:=xlDown
rij = rij + 2
Else
rij = rij + 1
End If
Loop While Not Cells(rij, kolom).Text = ""
End Sub