Во вложении файл с рабочей книгой MS Excel 2003
Sub abcd()
Dim n As Integer, a(1 To 8) As Integer
Dim r As Range
n = 8
imax = 1
Set r = Range(Cells(1, 1), Cells(2, 8))
r.ClearContents 'Очистка области
r.Interior.Color = RGB(255, 255, 255) 'Очистка цвета заливки
For i = 1 To n
a(i) = Int(30 * Rnd)
If a(i) > a(imax) Then imax = i
Cells(1, i) = a(i)
Next
t = a(imax)
Cells(1, imax).Interior.Color = RGB(204, 255, 255)
Range(Cells(1, 1), Cells(1, imax - 1)).Interior.Color = RGB(255, 255, 153)
For i = imax - 1 To 1 Step -1
a(i + 1) = a(i)
Next
a(1) = t
For i = 1 To n
Cells(2, i) = a(i)
Next
Cells(2, 1).Interior.Color = RGB(204, 255, 255)
Range(Cells(2, 2), Cells(2, imax)).Interior.Color = RGB(255, 255, 153)
End Sub
Скачать вложение Excel (XLS)