Goedendag,
Ik heb een macro die identieke waardes zoekt en de rijen waar deze in voorkomen een kleur geeft.
Ik wil graag dat alleen in een vooraf gedefinieerde row (
wordt gezocht naar identieke waardes, maar dat lukt me niet.
Ik heb een en ander geprobeerd als: Columns("B:B").Select maar ergens failed dit script:
Macro:
-------------------------------------------------------------------------------------------------------------------
Public Sub HighlightDuplicateRows()
Dim r As Long
Dim C As Range
Dim V As Variant
Dim Rng As Range
Dim Color As Integer
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
Color = 44
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If V <> V1 Then
Color = Color - 2
If Color = 34 Then Color = 44
End If
V1 = V
If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).EntireRow.Select
With Selection.Interior
.ColorIndex = Color
.Pattern = xlSolid
End With
Else
Rng.Rows(r).EntireRow.Font.Bold = True
End If
Next r
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
--------------------------------------------------------------------------------------------------------------------------
Iemand een idee hoe ik dit op kan lossen ?
Alvast heel erg bedankt,
Mesjoggah
Ik heb een macro die identieke waardes zoekt en de rijen waar deze in voorkomen een kleur geeft.
Ik wil graag dat alleen in een vooraf gedefinieerde row (
Ik heb een en ander geprobeerd als: Columns("B:B").Select maar ergens failed dit script:
Macro:
-------------------------------------------------------------------------------------------------------------------
Public Sub HighlightDuplicateRows()
Dim r As Long
Dim C As Range
Dim V As Variant
Dim Rng As Range
Dim Color As Integer
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If
Color = 44
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If V <> V1 Then
Color = Color - 2
If Color = 34 Then Color = 44
End If
V1 = V
If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).EntireRow.Select
With Selection.Interior
.ColorIndex = Color
.Pattern = xlSolid
End With
Else
Rng.Rows(r).EntireRow.Font.Bold = True
End If
Next r
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
--------------------------------------------------------------------------------------------------------------------------
Iemand een idee hoe ik dit op kan lossen ?
Alvast heel erg bedankt,
Mesjoggah