View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default referencing range elements inside the macro

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....



--
Tim Williams
Palo Alto, CA


"Greg" wrote in message
...
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.


--
______
Regards,
Greg