Disclaimer: nobody needs to do my homework for me. I just want to know if what I want to do is even possible to automate in Excel, or if I’m going to have to do it by hand.
I have a terrible, terrible report designed by a sadist, that exports into XLSX files with single cells containing variable data like this. The blank lines are line breaks (soft returns):
CELL 1:
Country: United States
State: California
City: Fontana
Governance: Council-Manager
CELL 2:
Country: United States
State: California
County: San Bernardino
County Seat: San Bernardino
CELL 3:
Planet: Earth
Country: United States
State: California
State Flower: California Poppy
State Capital: Sacramento
My job is to extract the bolded items, which might be cities, counties, or states. There is other info that might or might not appear, such as state flower. Cities and counties will never appear together in the same record, so if I see either of those, I want the characters that follow either "City: " or "County: ", starting with the first letter after the space and stopping when a line break is reached (or the end of the record in that cell, example not shown, but it’s possible.)
State will always appear, but if neither City nor County is present, then I want the state. So out of the examples above, I want Fontana, San Bernardino, and California.
Any of these items might appear anywhere, as in the CELL 3 example where I want the state. The appearance of “Planet: Earth” puts the State on a different line than in the other examples, so I can’t assume I can grab a particular line in any case.
Is there any set of formulas that could achieve this? I’m no expert but I’m willing to study and learn.