FrenchCelt
Board Regular
- Joined
- May 22, 2018
- Messages
- 214
- Office Version
- 365
- Platform
- Windows
Hello,
I have a worksheet in which there are numerous columns that are indexed by a value in Row 1. For example, it might say 1 Odd, 1 Even, 2 Odd, 2 Even, and so on. Of course they aren't in any kind of order, and I would like to use a macro to rearrange the columns in a particular manner. I want to arrange them so they alternate by Evens and Odds per digit, so for example 1 Even, then 1 Odd, for however many of 1 Even and 1 Odd columns there are, then alternating with 2 Even and 2 Odd, and so on. Also, if there is only one kind of a category, then a blank column should be inserted to separate them. Here is an example of the original data:
And here is how it should look after rearranging the columns:
As you can see, there were two 1 Evens with no 1 Odds, so the two were separated by a blank column, then it went to 2 Even, 2 Odd, 2 Even, followed by two 2 Odds in a row, then 3 Even and 3 Odd.
Here is how they actually look for real...Before:
After:
Does anyone have any suggestions on how to code this?
I have a worksheet in which there are numerous columns that are indexed by a value in Row 1. For example, it might say 1 Odd, 1 Even, 2 Odd, 2 Even, and so on. Of course they aren't in any kind of order, and I would like to use a macro to rearrange the columns in a particular manner. I want to arrange them so they alternate by Evens and Odds per digit, so for example 1 Even, then 1 Odd, for however many of 1 Even and 1 Odd columns there are, then alternating with 2 Even and 2 Odd, and so on. Also, if there is only one kind of a category, then a blank column should be inserted to separate them. Here is an example of the original data:
Waves | 2 Odd | 1 Even | 2 Odd | 2 Even | 1 Even | 2 Odd | 2 Even | 3 Odd | 3 Even |
HOME DOOR | |||||||||
Shipment ID | 2221811 | 2221785 | 2221781 | 2221779 | 2221794 | 2221784 | 2221774 | 2221775 | 2221782 |
Carrier Code | WVAS. | WVAS. | WVAS. | WVAS. | WVAS. | ||||
3STOP | |||||||||
Store | 646 | 131 | 1777 | 2267 | 633 | 2375 | 1125 | 1579 | 646 |
CP/XD Indicator | XD | XD | XD | XD | XD | XD | XD | ||
Weight | 8891 | 32308 | 33789 | 32084 | 28859 | 29530 | 26510 | 24928 | 38180 |
Cube | 761 | 2180 | 2376 | 2157 | 2229 | 2311 | 1500 | 1660 | 2154 |
Lines | 12 | 1163 | 1098 | 1370 | 1429 | 749 | 343 | 763 | 1485 |
Cut Time | TU9AM | TU8PM | TU9AM | TU9AM | TU10PM | TU9PM | TU10PM | TU11PM | TU10AM |
And here is how it should look after rearranging the columns:
Waves | 1 Even | 1 Even | 2 Even | 2 Odd | 2 Even | 2 Odd | 2 Odd | 3 Even | 3 Odd | |
HOME DOOR | ||||||||||
Shipment ID | 2221785 | 2221794 | 2221779 | 2221811 | 2221774 | 2221781 | 2221784 | 2221782 | 2221775 | |
Carrier Code | WVAS. | WVAS. | WVAS. | WVAS. | WVAS. | |||||
3STOP | ||||||||||
Store | 131 | 633 | 2267 | 646 | 1125 | 1777 | 2375 | 646 | 1579 | |
CP/XD Indicator | XD | XD | XD | XD | XD | XD | XD | |||
Weight | 32308 | 28859 | 32084 | 8891 | 26510 | 33789 | 29530 | 38180 | 24928 | |
Cube | 2180 | 2229 | 2157 | 761 | 1500 | 2376 | 2311 | 2154 | 1660 | |
Lines | 1163 | 1429 | 1370 | 12 | 343 | 1098 | 749 | 1485 | 763 | |
Cut Time | TU8PM | TU10PM | TU9AM | TU9AM | TU10PM | TU9AM | TU9PM | TU10AM | TU11PM |
As you can see, there were two 1 Evens with no 1 Odds, so the two were separated by a blank column, then it went to 2 Even, 2 Odd, 2 Even, followed by two 2 Odds in a row, then 3 Even and 3 Odd.
Here is how they actually look for real...Before:
After:
Does anyone have any suggestions on how to code this?