AFAIK there isn't any way to do exactly what you are asking. Variable names are part of your code; using and accessing them as data would need reflection which is not something Excel VBA offers*.
But I don't think what you are asking is the best way to achieve what you want by a long way. What you seem to need is a way of storing (name, value) pairs and accessing both the name and the value. One straightforward way to do this is to use the Dictionary object.
There are alternatives if you need different functionality, e.g. using a pair of Arrays (one to hold the names, one to hold the values) - to make this neater you could write a class to keep the two together and implement whatever functions you need as methods.
Once you have the (name,value) pairs outputting them in a sorted list is straightforward. The simplest way is to write them to the spreadsheet and then use Excel's built-in Range.Sort
(see MSDN documentation).
Putting it all together (note this needs a reference to the Microsoft Scripting Runtime
library for the Dictionary
object):
Dim dict As New Dictionary
Dim ws As Worksheet, rng As Range
Dim ky As Variant, itm As Variant
Set ws = ThisWorkbook.Worksheets(1)
'Add items to dictionary
dict.Add "x", 5
dict.Add "y", 3
dict.Add "z", 8
'You can use these in code like this:
For Each ky In dict.Keys
Debug.Print "The value of " & ky & " is " & dict(ky)
Next ky
'you can change values
dict.item("z") = 10
dict.item("z") = 8
'Output the values and keys (the key/value arrays are horizontal while
'the range is vertical, hence transpose)
Set rng = ws.Range(ws.Cells(1, 1), ws.Cells(dict.Count, 2))
rng.Columns(1).Value = Application.Transpose(dict.Keys)
rng.Columns(2).Value = Application.Transpose(dict.Items)
'Sort them
rng.Sort Key1:=ws.Range("B1"), Header:=xlNo
*not easily anyway - there are some objects accessible through VBProject
which allow limited access to the code. But using that to do what you are asking for would be nigh on impossible.