Link to home
Start Free TrialLog in
Avatar of Fi69
Fi69

asked on

Excel undo my sub

Hello experts

I have the following procedure that applies styling to the selected cells, but I want to be able to press the Undo button.

How would I go about doing an undo procedure? I understand that it would need to take note of the range of cells and store the font name/size/bold/color for each cell and then reapply it, but I'm really not sure how to go about that. Maybe I'm off track with my thoughts there. Not sure. Help!!



Public Sub StyleHeading()
  ApplyHeading Selection
End Sub

Public Function ApplyHeading(ByVal r As Range)
 
 Dim c
 For Each c In r
    With c.font
        .Name = "Arial"
        .Size = 12
        .Bold = True
        .Color = RGB(0, 100, 177)
    End With
 Next
 
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of elimesika
elimesika
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial