Function....

Christopher lee

Board Regular
Joined
Jul 11, 2014
Messages
79
1)Cells((r + rowTO), MedianUETFinterceptTo) = Application.WorksheetFunction.Median(Round(Cells(r + rowTO, uETFinterceptTO)))

2)Cells((r + rowTO), MedianUETFinterceptTo) = Application.WorksheetFunction.Median(Cells(r + rowTO, uETFinterceptTO))

Any 1 can tell me why the 1st coding can be run but the 2nd coding gv me the "Unable to get the Median property of the WorksheetFunction class'' run time error 1004 ??


The 1st coding can be run but it gv me with the 0 result.....any 1 can tell me what the difference with using ''Round'' and without using ''Round'' ??
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Median needs at least one number, although getting the Median value of a single number appears pointless to me.

In 1) the round converts the null value to 0 but 2) appears to be passing the argument as a Range object. Try:

Cells((r + rowTO), MedianUETFinterceptTo) = Application.WorksheetFunction.Median(Cells(r + rowTO, uETFinterceptTO).value)
 
Upvote 0
thk for fast reply teeroy. It works but if not gv me a constant value.....for median if should gv me all the same value rite? y will like this???
 
Upvote 0
Cells((r + rowTO), MedianUETFinterceptTo) = Application.WorksheetFunction.Median((Sheets("k1").Cells(n, 31)))

If i try this coding it gv me the "Subscript out of range" error...... my uETFintercept is on column 31....
 
Upvote 0
What exactly are you trying to get to? If you only pass one number to the Median function, and your Range reference using Cells only points to a single number, it will return you that number.
 
Upvote 0
i want to get the median of the column of uETFintercept......so the function should take all the value on column 31 and then to calculate the median of the uETFintercept and then put in the new column i create it......
 
Upvote 0
Cells((r + rowTO), MedianUETFinterceptTo) = Application.WorksheetFunction.Median(CStr((Round(Cells(r + rowTO, uETFinterceptTO), 6))))


Like the coding above i also can get the median of the uETFintercept with 6 decimal point....but it gv me the difference value on every row.....u know how to get the exactly median value results??
 
Upvote 0
Try this as an example. I think it will show you how you need to revise your code;

Code:
Sub teeroy()
Dim r As Long, uETFinterceptTO As Long, rowTo As Long
Dim Temp() As Single
uETFinterceptTO = 31 'Column required
r = 2 'Start Row
rowTo = Cells(Rows.Count, uETFinterceptTO).End(xlUp).Row 'End Row
ReDim Temp(0 To (rowTo - r))
For i = 0 To (rowTo - r)
    Temp(i) = Round(Cells(i + r, uETFinterceptTO), 6)
Next i
MsgBox Application.WorksheetFunction.Median(Temp)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top