Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default frequency in VBA


When I recorded entering an array function with the macro recorder, i
got this result:


Code:
--------------------
Selection.FormulaArray = "=SUM(R[-3]C:R[-3]C[1]*R[-2]C:R[-2]C[1])"
--------------------


So for starters, i'd say you need to modify the line to
rn.Cells(i, 2).formulaArray = WorksheetFunction.Frequency(rg,
rn.Cells(i, 1))

If it doesn't work then, I don't know the answer, but I can look for
it. Just hola if you have a result.


--
Excelibur
------------------------------------------------------------------------
Excelibur's Profile: http://www.excelforum.com/member.php...o&userid=29788
View this thread: http://www.excelforum.com/showthread...hreadid=494946

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default frequency in VBA

Dirk wrote:
For i = 1 To no
rn.Cells(i, 2) = WorksheetFunction.Frequency(rg, rn.Cells(i, 1))
Next i


frequency returns an array, not a single number. You can't use it that way.

There will be no loop.
I tried to describe range using "i" and "no", but you can simplify it.

i = 1
range (cells(i,2),cells(no,2)).formulaArray =
worksheetfunction.frequency (rg, range(cells(i,1),cells(no,1))

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IQR of a frequency Lonehunter Excel Worksheet Functions 1 February 17th 11 03:52 PM
Frequency rossmolden Excel Worksheet Functions 4 February 7th 09 11:54 PM
Frequency Fred Roven Excel Worksheet Functions 2 May 31st 06 03:06 AM
histograms - frequency and relative frequency? confusedstudent Excel Discussion (Misc queries) 2 February 8th 06 08:20 AM
frequency sara Excel Discussion (Misc queries) 1 April 5th 05 08:15 PM


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"