I setup a function to take the columns with the x, y and slot variables as an input and output the mean value...but I seem to be having a fundamental error here.

On another note I have it setup so that when the function returns a value on the command button procedure...it will automatically fillDown the column with all the other values.

Help please.

Formula: copy to clipboard
mean = (100000 * slot number) + (300x)+y


Function meanVal(xCol As Range, yCol As Range, slotCol As Range) As Integer
'Dim comVal As Integer
'Dim comrang As Range
'Set comRang = Range("N2", Range("N2").End(xlDown))
meanVal = (100000 * slotCol.Value) + (300 * xCol.Value) + yCol.Value

End Function

Private Sub cmdMeans_Click()
Dim xrang As Range
Dim yrang As Range
Dim slotrang As Range
Dim comrang As Range


'Defining the columns to be set as variable inputs to comment column
Set slotrang = Range("P2", Range("P2").End(xlDown))
Set xrang = Range("T2", Range("T2").End(xlDown))
Set yrang = Range("U2", Range("U2").End(xlDown))

comrang = meanVal(xrang, yrang, slotrang)
comrang.FillDown

End Sub