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 What does this parameter mean?

Hi ManKind,

My question is based on the following line


Set c = r.Find("NA", SearchDirection:=xlPrevious)(2)


What does the (2) at the end of the line mean?



This line of code is an abbreviation for:

Set c = r.Find("NA", SearchDirection:=xlPrevious).Item(2,1)

and is equivalent to:

Set c = r.Find("NA", SearchDirection:=xlPrevious).Offset(1,0)

For a detailed discussion of this, Chip Pearson hosts an excellent article,
written by Alan Beban:

http://www.cpearson.com/excel/cells.htm


---
Regards,
Norman


"ManKind" wrote in message
...
My macro appears as follows

Dim r As Range, c As Range

Set r = Range(Range("B4"), Range("B4").End(xlDown))
Set c = r.Find("NA", SearchDirection:=xlPrevious)(2)
If Not c Is Nothing Then
Set r = Range(c, c.End(xlDown))
Range("D4").Resize(r.Count).Value = r.Value
End If

My question is based on the following line

Set c = r.Find("NA", SearchDirection:=xlPrevious)(2)

What does the (2) at the end of the line mean?

Thank you