I need to reformat a connected-data table in one Excel worksheet into a standard table layout in another worksheet. The problem is that the data-in worksheet will have volatile schema, so I can not count on the same cells always containing the same data. For example, when linking to one data-input, I get cell C2 as a total landbase area number, but if I bring in a different data-input, cell C2 is landbase name and C3 is landbase area.
So I need to identify certain cells by the value they contain, then take the next cell over from that and bring it into worksheet2 in a specific place. To make things trickier, I actually have to evaluate two cell values, and when the two values match certain criteria, then take the third cell in that row and use it in the reformatted worksheet.
For example, on the first dataset worksheet one might be:
A1: "Area D" B1: "1234ha" C1: "protected" D1: "1970"
A2: "Area B" B2: "1876ha" C2: "unprotected" D2: "1986"
A3: "Area C" B3: "654ha" C3: "protected" D3: "1965"
A4: "Area B" B4: "5556ha" C4: "protected" D4: "2011"
I need the reformatted sheet, regardless of the input schema, to be:
A1: "Area B" B1: "protected" C1: "2011" D1: "5556ha"
A2: "Area B" B2: "unprotected" C2: "1986" D2: "1876ha"
A3: "Area C" B3: "protected" C3: "1965" D3: "654ha"
A4: "Area D" B4: "protected" C4: "2011" D4: "1234ha"
or
The second dataset connected to might be:
A1: "2652ha" B1: "protected" C1: "Area A" D1: "1970"
A2: "767ha" B2: "protected" C2: "Area E" D2: "1966"
I need the reformatted sheet, regardless of the input schema, to be:
A1: "Area A" B1: "protected" C1: "1970" D1: "2652ha"
A2: "Area E" B2: "protected" C2: "1966" D1: "767ha"
So in this example I have to identify when "Area B" is valid but then sort out "protected" vs. "unprotected" and apply the proper area cell ("5556ha" or "1876ha") to that row in the reformatted worksheet.
How can I achieve this cell-shuffling when the incoming data structure is varied?