I am using working code, but this code has one drawback. The problem is that the gradient fill color is snapped to Select / Selection.
If dic.Exists(arr(1, n)) Then Cells(87, n + 1).Select
The macro highlights the required cells + the cell that was selected with the mouse. What / how should I change to select only the necessary cells (by condition)?
Sub G()
Dim dic As New Dictionary
Dim x, arr, iNum&, n&
Dim z As Range
Set z = [Q10]
iNum = Range("A85").Value2
Set wb = ThisWorkbook:
s1 = wb.Sheets("1").Range("C87").Value2
Windows("2.xlsx").Activate
n = Cells(Rows.Count, 48).End(xlUp).Row
arr = Range("A2:CD" & n).Value2
If Not IsArray(arr) Then Err.Raise xlErrNA
For n = 1 To UBound(arr, 1)
If arr(n, 77) = 1 Then
If arr(n, 37) = iNum And arr(n, 3) = s1 Then x = dic(arr(n, 73))
End If
Next n
ThisWorkbook.Activate
n = Cells(20, Columns.Count).End(xlToLeft).Column
arr = Cells(20, 2).Resize(1, n).Value2
z.Activate
For n = 1 To UBound(arr, 2)
If dic.Exists(arr(1, n)) Then Cells(87, n + 1).Select
With Selection.Interior
.Pattern = xlPatternLinearGradient
.Gradient.Degree = 0
.Gradient.ColorStops.Clear
End With
With Selection.Interior.Gradient.ColorStops.Add(0)
.Color = 65535
.TintAndShade = 0
End With
With Selection.Interior.Gradient.ColorStops.Add(1)
.Color = 10498160
.TintAndShade = 0
End With
Next n
End Sub