Results 1 to 1 of 1

vba code returning Run Time Error 1004 method 'undo' of object

Threaded View

Ironman vba code returning Run Time... 10-24-2012, 08:17 PM
  1. #1
    Forum Contributor
    Join Date
    01-16-2009
    Location
    Ill.
    MS-Off Ver
    Excel 2010
    Posts
    190

    vba code returning Run Time Error 1004 method 'undo' of object

    hello - I have this code that someone on this formn provided and it was working last week...now I'm getting a Run Time Error 1004 Method 'Undo' of Object _Application' failed. Basically this code should allow only edits in columns 7, 12 and 16.

    Here is the code:

    Option Explicit
    Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
        Select Case Target.Column
            Case 7, 12, 16
                'nothing, these columns are fine
            Case Else
            Application.EnableEvents = False
                Application.Undo
                Application.EnableEvents = True
                MsgBox "This column is not availabe for editing"
                sh.Range("a2").Select
                
        End Select
    
    
    End Sub
    An additional question, i have two other codes in the ThisWorkbook (one is Workbook_open() and the other is BeforeClose(). I'm assuming that I can have all three in the ThisWorkbook module, yes?

    UPDATE - - I went back to the other two OPEN and BEFOREClose codes and removed any type of updating, I had in the OPEN code to clear out cell value of B505. Deleted that line. The Run Time error is gone, but now the Change Code (shown above) just doesn't fire? Any suggestions on what might be missing??? Thanks!
    Last edited by Ironman; 10-24-2012 at 08:41 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1