View Full Version : [SOLVED] VBA Set Variable equal to macro function

02-10-2016, 09:04 AM
Hi Everyone,

I am new at VBA and would like someones expert opinion on this:

I am presently working on a sub procedure which includes the use of a function "Linterp",
Linterp requires a "range" and a "double" character to complete its operations,

I am trying to firstly assign the range, and the double value, and set the answer generated by "Linterp" to a function,

Here is my present code:

Private Sub displacement()

Dim y as Double
Dim x As Double
Dim x1 As Double
Dim Displacement as Double


(Doesnt Work)

x = WorksheetFunction.Linterp("BP8:BQ11", x1)

Cells(row, 71) = x

(This works)

displacement = WorksheetFunction.Sum(Range("BT17:BT42"))

Cells(row, 75).Value = displacement

End Sub

How can I call the linterp macro, assign its range and double character and assign it to a variable I can output ?

Your Help is greatly appreciated!,

02-10-2016, 09:14 AM
I assume Linterp is a UDF for which you have the code, and that the code is either in the same project, or you have referenced it:

x = Linterp(Range("BP8:BQ11"), x1)

02-10-2016, 09:35 AM
Thank you Very Much!!

This works great!