You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SubHist(m AsLong, rng AsRange)
' sample of how to load array from rangeDim Arr AsVariant
Arr = rng.Value
maxValue = WorksheetFunction.Max(Arr)
'pass range values to array' MsgBox (maxValue)Dim i AsLong, j AsLongDim Length AsSingleReDim breaks(m) AsSingleReDim freq(m) AsSingle'Assign initial value for the frequency arrayFor i = 1To m
freq(i) = 0Next i
'Linear interpolation
Length = maxValue / m
For i = 1To m
breaks(i) = Length * i
Next i
'Counting the number of occurrences for each of the binsFor i = 1To UBound(Arr)
If (Arr(i, 1) <= breaks(1)) Then freq(1) = freq(1) + 1If (Arr(i, 1) >= breaks(m - 1)) Then freq(m) = freq(m) + 1For j = 2To m - 1If (Arr(i, 1) > breaks(j - 1) And Arr(i, 1) <= breaks(j)) Then freq(j) = freq(j) + 1Next j
Next i
'Sheets("Summary").Select'Display the frequency distribution on the summary worksheet'For i = 1 To m' Cells(i + 40, 2) = breaks(i)' Cells(i + 40, 3) = freq(i)'Next i'Sheets("Transformed Data").SelectEnd Sub