Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Edit exel macro to undo

Posted on 2014-03-19
3
Medium Priority
?
116 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 2000 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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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 Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

715 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