I see what llkhoutx's saying too - it depends on what you mean by "variable" or by when you determine its value. If you've already suceeded in determining the value within your VBA, then use the solution I posted - if you have not yet determined it, then use llkhoutx's.
Just to be sure - if you are looking to have sub headings, then have a look at the sorting and grouping button on your toolbar.
-Sean