I am using this list to generate both a string of text including different options separated by comma AND generate a total value of chosen items based on the Grade. I can now do either, but not both.
I find that I can either select multiple values and place them as text strings separated by comma (current set-up) or preface each one of the items in the list with a number (Grade) followed by two underscores so that the return value will be numerical, but not both.
Don't "Search and Replace" the variable -- instead, use a "For Each line in EREFS_List" to process the chosen values one by one, building both your "text" and "sum" variables as you go.
If you can guarantee the format of "Some text: Grade <one-or-more-numbers> - More text" then the regular expression to use in your "For Each line" loop would be .*?: Grade (\d)+ -.* (which will allow you to go beyond single-figure grades).
You could extract the values from each line using regular expressions, but if this is a static list consider continuing what you've done with the "friendly list" format and put both the grade number and text, separated by something unique, before the double-underscore. For example, item 1 would be
You can then treat each line as an array and get the code with %Variable%eachLine[1]$$% and the text with %Variable%eachLine[2]$$%. That gives you a bit more flexibility with the format in the future because you're in control.
The reason I use type instead of paste, is that most of my work macros are to supplement poorly designed electronic medical records software which I access via Citrix, and for some reason I found that "paste" does not always work reliably on Citrix as opposed to "type" even though this is not my preference and takes longer to execute.
In KM this required the use of a loop to search each line, although there is a way to loop through all pattern matches instead – but it's more complicated.
In many scripting/programming languages the search would be a single line of code, and people get a bit confused by KM's way of doing things.
Ultimately the macro turned out to be a bit simpler than you thought. As Einstein said: "Make it (whatever it is) as simple as possible (as is reasonable) but no simpler."
I see you've sorted that out for yourself. Note that your original macro's "Prompt..." action has a "Default" of "0", which is why you get that initial filtering -- if you don't want it, leave "Default" blank.
Because I'm evil and was only showing you how to extract the values from each line, making you work out how to combine them. Chris is much nicer than me
Looping and adding, and looping and appending, to a variable are common operations and it's good to get comfortable with them by trying different ways of doing it for yourself.