Learn how to a build a cloud-first strategyRegister Now


Excel undo my sub

Posted on 2011-10-15
Medium Priority
Last Modified: 2012-05-12
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
End Function

Open in new window

Question by:Fi69
1 Comment
LVL 19

Accepted Solution

elimesika earned 2000 total points
ID: 36973697

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question