0

I have data like:

enter image description here

I need to locate (get row numbers) for cells starting with the letter A.

My current approach is to use a "helper" column. In B1 I enter:

=IF(LEFT(A1)="A",1,"")

and in B2 I enter:

=IF(LEFT(A2)="A",MAX($B$1:B1)+1,"")

and copy down. This identifies the rows of interest. Finally in C1 I use:

=IFERROR(MATCH(ROWS($1:1),$B$1:$B$23,0),"")

and copy down.

enter image description here

My goal is to eliminate the "helper" column.

The only two options I see are:

  • use an autofilter
  • use a VBA UDF

The autofilter approach is bad because the filter would have to be re-run whenever the data is refreshed. The UDF approach bad because the sheet must work in a VBA-free environment.

Is there any kind of formula or array formula that can get the row numbers or am I stuck with the "helper"column ??

2 Answers 2

1

Try this entered as an array formula with Ctrl+Shift+Enter:

{=SMALL(IF(LEFT($A$1:$A$23)="A",ROW($A$1:$A$23),9E+99),ROW())}

I presume your criteria is more complicated that this in your actual application, though. You can replace the LEFT($A$1:$A$23)="A" with any criteria you like and it'll still work.

Note that this will return 9E+99 if you copy it down for more rows than there are that start with "A". You could tweak it to return blank instead:

{=IFERROR(SMALL(IF(LEFT($A$1:$A$14)="A",ROW($A$1:$A$14),""),ROW()),"")}
3
  • PERFECT!! ...............this is exactly what I need. Apr 20, 2015 at 15:58
  • @Gary'sStudent I think the second formula is actually better. It'll return blanks if you copy it down too far. Apr 20, 2015 at 16:00
  • I agree.................I will also be able to use your results in INDEX() formulas to retrieve data in other columns as well ! Apr 20, 2015 at 16:03
1

Try this:
Put 0 in C1.
From C2: =match(indirect("a"&c1+1&":a<last row>",true),"a*",0)+C1
Notes: Match is not case sensitive. You need to manage errors after ask the matches are found.

1
  • Thanks! ..................I had to reverse the arguments to MATCH(), but this worked =MATCH("A*",INDIRECT("A"&C1+1&":A23",TRUE),0)+C1 I guess each MATCH() starts where the previous one stopped. Apr 20, 2015 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .