I have eight different variables that can have a value or no value. They look something like this:
A= "h"
B= "(z)"
C= "a"
D= ""
E= "[st]"
F= ""
G= "xx"
H= "(t)"
I need them all together in alphabetical order (must include the brackets):
Aim= "a,h,[st],(t),xx,(z)"
I know how to put them in one string and how to put the "," in the right place.
How do I put them in alphabetical order, while ignoring the brackets?
To exclude the emtpy values and add the commas I use for every value:
If IsEmpty(HH) = False Then HHH = HH.Value & ","
To put them together I use the "&" function
StrHoribez = BBB & CCC & DDD & EEE & FFF & GGG & HHH & III
To remove the last comma I use:
If Right$(StrHoribez, 1) = "," Then StrHoribez = Left$(StrHoribez, Len(StrHoribez) - 1)
The alphabetical sorting can happen in between any of these steps.
How can I approach this? Maybe something with an array but I have no experience using these.