Попробуйте так, не даю гарантий, что правильно, нужно проверять
Код |
---|
Sub ГруппированнаяВыборка_1()
Dim c As Range
Dim k As Integer
i = 1
s = Abs(Val(InputBox("Введите номер столбца")))
If s < 1 Then Exit Sub
Do While Not IsEmpty(Cells(i, CInt(s)))
i = i + 1
Loop
n = i - 1
xmin = Cells(1, 1)
xmax = Cells(1, 1)
For Each c In Range(Cells(1, 1), Cells(n, CInt(s)))
If xmin > c Then xmin = c
If xmax < c Then xmax = c
Next c
k = Int(1 + 3.32 * Log(n) / Log(10))
R = xmax - xmin
h = Round(R / k, 2)
Cells(2, 13) = "№"
Cells(2, 14) = "левая граница"
Cells(2, 15) = "правая граница"
Cells(2, 16) = "среднее значение"
Cells(2, 17) = "частота"
For i = 1 To k
Cells(i + 2, 13) = i
Cells(i + 2, 14) = xmin + (i - 1) * h
Cells(i + 2, 15) = xmin + i * h
Cells(i + 2, 16) = (Cells(i + 2, 14) + Cells(i + 2, 15)) / 2
n1 = 0
For Each c In Range(Cells(1, 1), Cells(n, CInt(s)))
If c >= Cells(i + 2, 14) And c <= Cells(i + 2, 15) Then n1 = n1 + 1
Next c
Cells(i + 2, 17) = n1
Next i
End Sub |
Нужно ввести номер последнего столбца