tags:

views:

165

answers:

4

Here is a reduced version of what I need. Essentially, we have a list of components and their status (imagine they have been tested). Component BBB has two sub-components, BBB1 and BBB2. I want their status to reflect that of the BBB component 'parent'. Easily done, apart from the list is very long, and I need to retain the option to sort it as I wish. If I user a simple cell reference to "=B3", then this is invalid once the list is sorted. Similarly with a named range as B3; the named range address is static and does not dynamically alter when the list is sorted.

I could fix this by having a 'static' BBB status somewhere that is not in the sort area, but this is inelegant, and I don't like inelegance!

Any ideas?

http://FileHost.JustFreeSpace.Com/158complist.xls

A: 

Perhaps the VLOOKUP worksheet function does what you need? See http://office.microsoft.com/en-us/excel/HP052093351033.aspx

barrowc
Unfortunately, VLOOKUP will only work correctly when the list is sorted alphabetically; I cannot guarantee this.
Chris Gunner
@Chris Gunner: According to the linked docs, VLOOKUP doesn't require the list to be sorted if you are looking for an exact match.
John Y
A: 

There's a very easy solution. Just used an absolute reference, e.g. =$B3 or =B$3 or =$B$3

If I user a simple cell reference to "=B3", then this is invalid once the list is sorted.

Sorting won't invalidate these absolute references.

Aaron F.
Sorting using the AutoFilter drop-down does, I'm afraid. I need something which will stay relative during these 'sorts' (which appear to be different from a *proper* sort as you describe.
Chris Gunner
A: 

If you're just using =B3, on sorting Excel will update that on its own when you sort, as long as you don't sort using VBA. If you want to keep a handle on that cell, you may need to find it again manually or keep tabs on where it goes to as you move it around.

A. Scagnelli
+1  A: 

I'm not fully sure of your use and needs, but try this litte formula:

=ADDRESS(MATCH("BBB",A:A,0),1)

It will return the cell address where BBB sits. If you remove the ADDRESS portion of the formula, it will return the Row number.

It can also be modified to pull the Value in your 'Status' Column.

If you put this formula in the 'Status' column for rows BBB1 & BBB2, then it will update when BBB changes:

=INDEX(A:C,MATCH(LEFT(A2,3),A:A,0),2)

Let me know if I'm only warm, or if I got it.

JustPlainBill
That's fantastic. A little slow on a list of 600 'components', but nonetheless effective/
Chris Gunner
You could cut the range down to your required size: <br><br>=INDEX(INDIRECT($F$1,TRUE),MATCH(LEFT(A2,3),INDIRECT($G$1,TRUE),0),2) <br><br>The first INDIRECT refers to cell F1, place your range, as a string in there, for example: A2:C600.<br><br>The second INDIRECT refers to cell G1, place your range that will contain your component codes (BBB, BBB1, BBB2, etc.). In the sample it's in Column A, so: A2:A600. <br><br>That should speed it up significantly.<br>
JustPlainBill