What does this parameter mean?
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 |
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 |
All times are GMT +1. The time now is 03:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com