Vba. как переделать этот код , что б он считал и менял меж собой минимальные и максимальные элементы не столбцов,а строк? private sub commandbutton1_click() dim s() as integer, n as integer, m as integer dim i as integer, j as integer dim min as integer, max as integer cells.clear n = inputbox("ctroki", , 4) m = inputbox("ctolbec", , 5) randomize redim s(n, m) as integer for j = 1 to m max = -100: min = 100 for i = 1 to n s(i, j) = rnd() * 60 - 10 cells(i + 1, j + 1) = s(i, j) cells(i + 3 + n, j + 1) = s(i, j) if min > s(i, j) then min = s(i, j) q = j end if if max < s(i, j) then max = s(i, j) w = j end if next s(i, q) = min cells(w + 3 + n, j + 1) = s(w, j) s(i, w) = max cells(q + 3 + n, j + 1) = s(q, j) next end sub
Dim s() As Integer, n As Integer, m As Integer
Dim i As Integer, j As Integer
Dim min As Integer, max As Integer, q As Integer, w As Integer
Cells.Clear
n = InputBox("CTROKI", , 4)
m = InputBox("CTOLBEC", , 5)
Randomize
ReDim s(n, m) As Integer
For i = 1 To n
max = -100: min = 100
For j = 1 To m
s(i, j) = Int(Rnd() * 60 - 10)
Cells(i, j) = s(i, j)
Cells(i + 2 + n, j) = s(i, j)
If min > s(i, j) Then
min = s(i, j)
q = j
End If
If max < s(i, j) Then
max = s(i, j)
w = j
End If
Next j
Cells(i + 2 + n, w) = min
Cells(i + 2 + n, q) = max
Next i
End Sub