Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

[SOLVED] Swapping 2 cells in a row based on cell contents

$
0
0
Hello all,

I'm in the following situation:

D................E.....................................F

Age..........Town..............................State

77..........amariburgh....................MISSISSIPPI
75..........hayeshaven....................NORTH CAROLINA
35..........east isabellville....................Georgia
34..........LESCHPORT....................Tennessee
47..........hoegerborough....................North carolina
47..........CUMMERATABERG..........Texas
32..........leschport ....................tennessee
67..........leschport....................tennessee
30..........north carolina..........LUBOWITZTON
76..........ALBACHESTER....................texas
40..........NORTH CAROLINA..........Lubowitzton
21..........north nickolas....................virginia
53..........port adonis....................TENNESSEE
54..........LUBOWITZTON....................north carolina
24..........Louisiana....................NEW ROGERS


If you scan down the list you'll see that there are quite a few where the town and state are the wrong way round.
(in this small selection, North Carolina and Louisiana)

Can anyone come up with a macro which swaps the 2 cells in columns E and F if a particular string (a state) is found in the town column?
Obviously it'll have a number of state names - although there's actually only 11 in the sheet.

I was thinking about cutting all state names to a new column (G) from both E & F and then concatinating the remaining towns in E & F, but at the moment even that has me stumped...

I've attached a small section of the spreadsheet
- note, don't worry about the messy font cases and non delimitated names - I've got macros written for both of those. :)

Thanks everyone!...
Indelible
Attached Files

Viewing all articles
Browse latest Browse all 50090

Trending Articles