Very sloppy code and incorrect, below the corrected for next loops
code]
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim Rng1 As Range
Dim CompareRange As Range
Dim Rng2 As Range
Dim CompareRange2 As Range
Dim x As Variant
Dim y As Variant
Set CompareRange = Worksheets("Ladu").Range("B4:B")
Set Rng1 = Worksheets("Sheet1").Range("N16:N")
Rng1.SpecialCells(xlCellTypeConstants).Select
CompareRange.SpecialCells(xlCellTypeConstants).Select
For Each x In Rng1
For Each y In CompareRange
If x = y And Worksheets("Sheet1").cell(x, 9).Value < Worksheets("Ladu").cell(y, 9).Value Then
Worksheets("Sheet1").cell(x, 9).Value.EntireRow.Delete
Else
End If
Next y
Next x
Application.ScreenUpdating = True
End Sub
[/code]
But then ...
apart from that the two red marked lines, the first, that sheet is not present (as far as I can see)
What is the lat row in N?
The RefreshallDataConn in Laoseis is wrong, I'm sure you didn't even test it.
I didn't even take the time to look further
Bookmarks