Question

I have a project that requires me to clean a set of data and then produce reports based on this data. One part of the cleaning process is to sort two columns, one of which includes town and one that includes state. In some of the rows, the town is in the state column and the state is in the town column, but this is not true for all cases, some are in the correct columns.

We are required to use either Excel's functions, and if there is not an efficient method, turn to VBA.

How am I supposed to do this in either case?

Was it helpful?

Solution

Make a list of all States (say in ColumnE, assuming your data is in ColumnA:B starting in Row2) and in:

C2 enter: =VLOOKUP(A2,E:E,1,0)
D2 enter: =VLOOKUP(B2,E:E,1,0)

copy both down to suit.

Sort A:C on ColumnC and for #N/A values in ColumnC switch over columns A and B. Reinstate the formulae for those rows, then sort A:D on ColumnD and for values other than #N/A switch over Columns A and B.

Redo formulae as a check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top