Categorical data into numeric in excel
Why don't you import the data into R and use some built-in function for encoding? createDummyFeatures from mlr package is a function, which can do one-hot encoding of categorical variables.

https://www.rdocumentation.org/packages/mlr/versions/2.13/topics/createDummyFeatures