seattletimebandit
Board Regular
- Joined
- Apr 11, 2013
- Messages
- 69
Hello All,
I've been trying to find a way to search down a single column and based on the text value in a cell, enter a numerical value in the adjacent cell to the left. I want to be able to assign the numbers to allow me to sort the text columns in a particular order, by using the numbers in the adjacent column. I'm thinking a CASE SELECT scenario.
Here are the tables before and after adding the sort number, and the table after sorting the data:
[TABLE="width: 863"]
<tbody>[TR]
[TD][/TD]
[TD="colspan: 2"]Before Adding Sort Number[/TD]
[TD][/TD]
[TD]After Adding Sort Number[/TD]
[TD][/TD]
[TD][/TD]
[TD]After Sorted[/TD]
[/TR]
[TR]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[TD][/TD]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[TD][/TD]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[/TR]
</tbody>[/TABLE]
Thanks for your help in advance!
stb
I've been trying to find a way to search down a single column and based on the text value in a cell, enter a numerical value in the adjacent cell to the left. I want to be able to assign the numbers to allow me to sort the text columns in a particular order, by using the numbers in the adjacent column. I'm thinking a CASE SELECT scenario.
Code:
Select Case score
Case "Benzene"
result = "1"
Case "Ethylbenzene"
result = "2"
Case "Toluene"
result = "3"
Case "m, p-Xylene"
result = "4"
Case "o-Xylene"
result = "5"
Case "Gasoline"
result = "6"
'etc.
End Select
Here are the tables before and after adding the sort number, and the table after sorting the data:
[TABLE="width: 863"]
<tbody>[TR]
[TD][/TD]
[TD="colspan: 2"]Before Adding Sort Number[/TD]
[TD][/TD]
[TD]After Adding Sort Number[/TD]
[TD][/TD]
[TD][/TD]
[TD]After Sorted[/TD]
[/TR]
[TR]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[TD][/TD]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[TD][/TD]
[TD]Sort_Order[/TD]
[TD]List[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]Benzene[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]Ethylbenzene[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]Gasoline[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]m, p-Xylene[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]5[/TD]
[TD]o-Xylene[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]2[/TD]
[TD]Toluene[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]Gasoline Range Organics[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[TD][/TD]
[TD]9[/TD]
[TD]#2 Diesel[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]Diesel Range Organics[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[TD][/TD]
[TD]10[/TD]
[TD]Lube Oil[/TD]
[/TR]
</tbody>[/TABLE]
Thanks for your help in advance!
stb
Last edited: