Hello-
Trying to write an excel VBA function which will populate a range of cells with values
Here is the Code
Function setvalue(UnitPrice, Qty, Freight, R)
'R is a range of cells
'Set the sales Price
R.Cells(1).Formula = Qty * (UnitPrice + Freight)
' calculate freight
R.Cells(2).Formula = Qty * Freight * -1
'Calculate Net
R.Cells(3).Formula = R.Cells(1).Value + R.Cells(2).Value
setvalue = 0
End Function
This function seems to set the R.Cells(1) and stops. Also, the Cell which calls the function displays a #value instead of Zero.
Any help would be appreciated....
Cheers!
Trying to write an excel VBA function which will populate a range of cells with values
Here is the Code
Function setvalue(UnitPrice, Qty, Freight, R)
'R is a range of cells
'Set the sales Price
R.Cells(1).Formula = Qty * (UnitPrice + Freight)
' calculate freight
R.Cells(2).Formula = Qty * Freight * -1
'Calculate Net
R.Cells(3).Formula = R.Cells(1).Value + R.Cells(2).Value
setvalue = 0
End Function
This function seems to set the R.Cells(1) and stops. Also, the Cell which calls the function displays a #value instead of Zero.
Any help would be appreciated....
Cheers!