View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
John Foddrill John Foddrill is offline
external usenet poster
 
Posts: 1
Default Insert Rows within Function

Currently the function below returns values and I have the seperated by
carrage return, however i wan to have all the values returned seperated into
new rows. Is there a way to get the data back seperated into new rows using
a subroutine?



Function MLookup(LookupRng As Range, OffsetVal As Integer, LookupVal As Range)
Dim r As Range

For Each r In LookupRng

If r.Value = LookupVal.Value Then
If Len(MLookup) = 0 Then
MLookup = r.Offset(0, OffsetVal - 1).Value
Else

MLookup = MLookup & vbCrLf & r.Offset(0, OffsetVal - 1).Value
End If
End If
Next r
End Function