Debug with no error (1 Viewer)

mdjks

Registered User.
Local time
Today, 12:07
Joined
Jan 13, 2005
Messages
96
I am getting a debug at the End If right after ActiveWorkbook.Save. I don't have to do any thing but hit F5 and it finishes. Any suggestions? I need to get this to end users in the next few minutes.

Using Excel 2013 on Win 8 this is the complete piece of code




Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


Application.ScreenUpdating = False
Dim uName As String
uName = Environ("username")
Application.EnableEvents = False


If uName = "cwoolno" Then
Dim anSwers As Integer

anSwers = MsgBox("Do you want to copy?", vbYesNo)
If anSwers = vbNo Then
   GoTo noupdate2
   Else

    
  ActiveSheet.Unprotect

 
    Sheets("bkup").Visible = True
    Sheets("Win10").Select
    Cells.Select
    Selection.Copy
    Sheets("bkup").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("bkup").Select
    'ActiveWindow.SelectedSheets.Visible = False
    Sheets("Win10").Select
    Range("B2").Select
    Application.CutCopyMode = False
      ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFiltering:=True
    ActiveWorkbook.Save


'This is where the error happens
End If
noupdate2:


End If

Application.EnableEvents = True
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:07
Joined
Feb 19, 2013
Messages
16,614
because of your goto

goto's should be used with care - try moving your end if to below noupdate2:
 

Users who are viewing this thread

Top Bottom