Sub test()
Dim nb&, C1&, C2&, Cx1, Cx2, Px1&, Px2&, Px3&
nb = 20
Cells(1, 1).Resize(nb, 2).Clear
C1 = vbRed: Cx1 = longToRGB(C1)
C2 = vbGreen: Cx2 = longToRGB(C2)
Px1 = Round(-(Cx1(1) - Cx2(1)) / (nb - 2))
Px2 = Round(-(Cx1(2) - Cx2(2)) / (nb - 2))
Px3 = Round(-(Cx1(3) - Cx2(3)) / (nb - 2))
For i = 1 To nb
rp = Cx1(1) + (Px1 * (i))
gp = Cx1(2) + (Px2 * (i))
bp = Cx1(3) + (Px3 * (i))
Cells(i, 1).Interior.Color = RGB(Cx1(1) + rp, Cx1(2) + gp, Cx1(3) + bp)
Next
Cells(1, 2).Interior.Color = C1
Cells(nb, 2).Interior.Color = C2
End Sub
Function longToRGB(c)
Dim t(1 To 3)
t(1) = c Mod 256
t(2) = ((c - t(1)) / 256) Mod 256
t(3) = ((c - t(1) - (t(2) * 256)) / 256 / 256) Mod 256
longToRGB = t
End Function