referencing range elements inside the macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am creating a UD function of the following form Function interpolate(z,
inputX as Range , inputY as Range)

In the body of the function, I need to cross-reference elements of inputX
with inputY ranges.

If it were a spreadsheet, I could use lookups, offset, match, index
functions. I am not really sure how to do this in VBA inside the function.

Can someone please illustrate this with a few examples of sample code?

For example, I need to find an element in inputY with a position
corresponding to inputX and perform some math on it. So, if 17 is in the
third position in inputX , I want to get a corresponding inputY element.


Hope it is not overly confusing.

Thank you for your help.
 
Function interpolate(z, inputX as Range , inputY as Range)

dim i as long
'should check here that ranges are the same size

for i = 1 to inputX.cells.count

'here you can work with
'inputX.cells(i)
'inputY.cells(i)

next i

etc....
 
Back
Top