Solved

Edit exel macro to undo

Posted on 2014-03-19
3
97 Views
Last Modified: 2014-08-05
Hello,

Is there a way to undo a macro. Refer to my other Make excel macro available to all users link for the creation and implementation of the macro, typing ctl + L. Right now that function doesn't work.

Thanks
0
Comment
Question by:rha_mtl
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39939759
To be able to do an Undo

you have to code the undo

Sub MyMacro()
'YourCode
Application.OnUndo "Undo the last macro", "UndoMyMacro"
End Sub

Sub UndoMyMacro()
'YourUndoCode
End Sub

Open in new window

Regards
0
 

Author Comment

by:rha_mtl
ID: 39939815
Hello,

A little confused on where to apply this.

The code I use is

Sub CopyPicture()
Dim WSThis As Worksheet
Dim WS As Worksheet
Dim Img As OLEObject
Dim WSImg As OLEObject

Set WS = ActiveSheet
Set WSThis = ThisWorkbook.Worksheets("Main")

On Error Resume Next
Set WSImg = WS.OLEObjects("Image1")
If Err = 0 Then
    
Else
    Set Img = WSThis.OLEObjects("Image1")
    Img.Copy
    WS.Range("A1").PasteSpecial
End If
On Error GoTo 0

End Sub

Open in new window



Would I select the keys ctl + L to run the undo code. Much like how I do ctl + L to apply run the code
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39939842
That would be on line 20

but on your case I don' see how it would be possible to do a reverse command for the paste special

Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

937 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now