The code below do not work properly. The problem is that it seems that the next line is executed before the command given by the former line completely finish the output to the screen.
So, what command imposes Excel to wait completely for a subprocedure to completely finish before execute next line?
#If VBA7 Then
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64 Bit Systems
#Else
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32 Bit Systems
#End If
Sub SweepLinesAndPaintYellowActiveCell()
lastline= Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lastline
Cells(i, 1).Select
ActiveCellYellow
Sleep 25
ActiveCellWhite
Next i
End Sub
Sub ActiveCellYellow()
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Sub ActiveCellWhite()
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub