View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default How do I calculate an offset between two ranges?

Hi Mo,

Try something like,
'============
Function Myoffset(x As Range, y As Range, test As String)
Dim i As Long

If x.Count < y.Count Then Exit Function

For i = 1 To x.Count
With x(i)
If .Value = test Then .Value = y(i).Value
End With
Next
End Function
'============

---
Regards,
Norman



"mo childs" wrote in message
...
x and y are single column ranges of the same size. How do I retrieve
the corresponding values to x & from y as I loop through x? See
example below and thanks for any help.

Function offset(x As Range, y As Range, test As String)

For Each icell In x
If icell.Value = test Then
' I want to use the value of the corresponding element of range y here
End If
Next

End Function

--
Mo