So this is a little out the sideline, but:

Whenever I do some code in VBA, I have to document this, either to myself in OneNote or in reports in Word. However, it seems impossible to copy VBA code from the editor to anything else and preserve the formatting.

Basically I end up with this:
'event handler for the run button 
Private  Sub  btnRun_Click()
Dim  i As  Integer 
'loops through the cells in row 2 
For  i = 1 To  6
    'checks if the wrap property is on 
    If  Range(Cells(2, i), Cells(2, i)).WrapText = True Then  
        'colors the cell green 
        Range(Cells(1, i), Cells(1, i)).Interior.Color = 3394611 
    Else  
        'removes any previous color assigned to the cell 
        Range(Cells(1, i), Cells(1, i)).Interior.Color = xlNone 
    End If  
Next  i
End  Sub
While I would really like as presented here with colours and indents (mostly the colours).

Are there any way to do this, or and online tool I simply cannot find? It makes reading the code in the future so much easier and elegant in reports.


I hope you can help,


GregersDK