Solved

Edit exel macro to undo

Posted on 2014-03-19
3
111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

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 52

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

617 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