This rearrange function is just wonderful!... but I am having trouble getting it to do what I need in my context. Mainly because I lack both the regex and the VBA necessary.
Questions (help with any one is deeply appreciated):1. The rearrange seems to work on “sort the words in this order if the match is exact”. I would like it to have the sort be based on “sort the words when the words begin with”.
2. This function returns nothing when your sort words have special characters in them. My context is that I have lines that have macro variables in them where the macro variables vary in how they are delimited.
As examples… I have the lines “~s=male~,!a=11!, @r=Hispanic@,#y=40000#” AND “~s=female~,!a=10!, @r=Hispanic@,#y=30000#”
On the first line: *** is male, age is 11, race is Hispanic, income is 40000. I would like to rearrange this so the Y’s always come first, S’s come second, R’s come third, and A’s come last… regardless of what their value is and regardless of what their delimiter is. Is this possible? Can one quote the special characters somehow?
3. Can the sort words be passed to the function as a range (i.e., to the array assignment line) like in the earlier variation by DonkeyOte?
Thank you so much!
Brendan
lexce wrote:
>>>>

Originally Posted by
lecxe
Hi
I tested this UDF with the examples you posted. It accepts more than 3 comma-delimited substrings and duplicate keywords.
If you find errors please post examples.
Use:
=Rearrange(A1)
Bookmarks