/ Published in: Visual Basic
Создание процедуры Ñ Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ñ‹Ð¼ чиÑлом параметров и обработка Ñтих параметров
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Function IsMediana(M As Variant, Cand As Variant) As Integer Dim Pos As Integer, Neg As Integer Pos = 0: Neg = 0 If TypeName(M) = "Range" Then For i = 1 To M.Rows.Count For j = 1 To M.Columns.Count If M.Cells(i, j) > Cand Then Pos = Pos + 1 ElseIf M.Cells(i, j) < Cand Then Neg = Neg + 1 End If Next j Next i IsMediana = Pos - Neg ElseIf TypeName(M) = "Variant()" Then 'TypeName is "Variant()" Dim Val As Variant For Each Val In M If Val > Cand Then Pos = Pos + 1 ElseIf Val < Cand Then Neg = Neg + 1 End If Next Val IsMediana = Pos - Neg Else MsgBox ("") End If End Function
URL: http://www.intuit.ru/department/office/vbaexcel/2/vbaexcel_2.html