Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 686

Best Way to convert a column of strings into numbers

$
0
0
Hi!

I currently have a column with strings (names of animals) and I want to convert each animal name to a number (cow-> 1, zebra->3 etc.) with the numbers being based on an order that I set- meaning I need cow to be 1 and zebra to be 3, I can't just order them in an arbitrary way (sample file attached). What would be the best way to do that using VB?

Also, some of the names have hypens (-) in the string. Not sure if that affects anything, but just letting you know

Technically, I could do a Case Statement but in the complete file I have 32 names, so i didn't feel that writing 32 cases was so efficient...

Please let me know if you have any suggestions!

Thanks so much!
Attached Files

Viewing all articles
Browse latest Browse all 686

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>