Richard
That makes it quite a bit more complicated, at least for me. Someone like Bob who does magic with Functions will chime in I'm sure. The solution I have come up with uses a UDF (User Defined Function). (as below)
'------------------Start Code---------------------
Public Function FindHeading(sOrder As String, rLookup As Range) As String
Dim rng As Range
Application.Volatile True
Set rng = rLookup.Find(sOrder)
If Not rng Is Nothing Then
FindHeading = Range(Cells(1, rng.Column), Cells(1, rng.Column)).Value
Exit Function
End If
FindHeading = "N/A"
End Function
'-------------------------------------End Code----------------------------------------
To implement this, open the workbook, press F11 and in that window go to 'Insert>Module'. Paste the code here and close the window (You will need to save the workbook and remember you will get a Macro warning when opening (or in Excel 2007 the security bar will show).
Without doubt a industry strength function would need more error checking, but for your use it works at least.
The function takes two parameters, the order number and the range that the numbers can be found in. To use, you just do exactly as you would with any built in function, so for example in E2 you would enter
=FindHeading(A2,$F$2:$Q$6748)
That returns preliminaries (or in fact whatever is in the heading directly above where the order number is found, so if you change that and re-calc, the references will update too.
As it is looking at so much data, there is a lag between making changes and the formula updating
Regards
Nick Hodge
Microsoft MVP, Excel
Southampton, UK