View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dirk[_4_] Dirk[_4_] is offline
external usenet poster
 
Posts: 6
Default frequency in VBA

Dear all

at the end of this subroutine I am using the frequency function but I
need the {} around it in order to be calculated correctly. How can I do
this?

Sub histo()
Dim rg, rn As Range
Dim i, no As Integer
Dim rep1, rep2 As String
Dim max, min As Double

rep1 = InputBox("define the range of the variable")
Set rg = Range(rep1)

no = InputBox("insert the number of bins, otherwise leave empty")
'If no = Nothing Then no = rg.Rows.Count / 10

rep2 = InputBox("where should i put the bins")
Set rn = Range(rep2)

max = WorksheetFunction.max(rg)
min = WorksheetFunction.min(rg)
For i = 1 To no
rn.Cells(i, 1) = min + i * (max - min) / no
Next i
For i = 1 To no
rn.Cells(i, 2) = WorksheetFunction.Frequency(rg, rn.Cells(i, 1))
Next i

End Sub