After executing the following code, I see part of worksheet1 and part of worksheet2 when I expect to see all of worksheet2 and only worksheet2 (worksheet2 = "working sheet" in the example):
Dim k As Integer
Dim sh1 As Worksheet: Set sh1 = Sheets("working sheet")
sheet_name = "working sheet"
Sheets(sheet_name).Range("B24:AO24").Value = ""
sh1.Visible = True
sh1.Select
For k = 3 To 41 Step 2
sh1.Cells(24, k).Select
If WorksheetFunction.IsNumber(Sheets(sheet_name).Cells(3, k).Value) Then
Selection.Interior.Color = &H20FFFF 'set color to yellow
Else
Selection.Interior.Color = xlNone 'clear all color
End If
Next k
. . . . .
After executing the following code, I see part of worksheet1 and part of worksheet2 when I expect to see all of worksheet2 and only worksheet2 (worksheet2 = "working sheet" in the example):
Dim k As Integer
Dim sh1 As Worksheet: Set sh1 = Sheets("working sheet")
sheet_name = "working sheet"
Sheets(sheet_name).Range("B24:AO24").Value = ""
sh1.Visible = True
sh1.Select
For k = 3 To 41 Step 2
sh1.Cells(24, k).Select
If WorksheetFunction.IsNumber(Sheets(sheet_name).Cells(3, k).Value) Then
Selection.Interior.Color = &H20FFFF 'set color to yellow
Else
Selection.Interior.Color = xlNone 'clear all color
End If
Next k
. . . . .
Maybe try unhiding after the updates?
Dim k As Long
With ThisWorkbook.Worksheets("working sheet") 'or ActiveWorkbook, etc
.Range("B24:AO24").Value = ""
For k = 3 To 41 Step 2
.Cells(24, k).Interior.Color = _
IIf(IsNumeric(.Cells(3, k).Value), &H20FFFF, xlNone)
Next k
.Visible = True
.Select
End With
It seems I've found a solution: whenever I update something that I want to see on the screen while vba is still running, I execute
Application.ScreenUpdating = True
Application.Wait (Now + TimeValue("0:00:01"))
Application.ScreenUpdating = False