• 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

Ответы 1

  • 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, 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 iEnd Sub
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years