Thread: Compile Error
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sprinks Sprinks is offline
external usenet poster
 
Posts: 86
Default Compile Error

The following macro is triggering a "Block If Without End If" compile error
when invoked, but the necessary End If seems to be there.

Thanks for any assistance.

Sub ToggleNotes()
' Toggles visibility of Notes worksheet; inserts if not yet inserted
' If on the master Macros sheet, toggles visibility of the MenuSheet
' Ctrl-n

Dim intSheet As Integer
On Error GoTo ErrHandler

If ActiveWorkbook.Name = "Macros.xls" Then
With Sheets("MenuSheet")
.Visible = Not Sheets("MenuSheet").Visible
.Activate
End With
Else

' If Notes sheet doesn't exist, add, else toggle visibility and
activate
If Not SheetExists("Notes") Then
Sheets.Add
Type:="\\Diamond\Departments\Cost_Estimating\Templ ates\Notes.xlt"
ActiveWorkbook.Sheets("Notes").Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets .Count)

Else

Application.ScreenUpdating = False
With Sheets("Notes")
.Visible = Not Sheets("Notes").Visible
.Activate
End With

End If

If Sheets("Notes").Visible = False Then

'If multi-page, select page to return to, otherwise return to
Sheet1
If ActiveWorkbook.Sheets.Count 2 Then
intSheet = InputBox("Enter sheet number to return to:",
"Sheet Number", 2)
Sheets(intSheet).Activate
Else
Sheets(1).Activate
End If

Application.ScreenUpdating = True

End If

ErrExit:
Exit Sub

ErrHandler:
MsgBox "There has been the following error. Please contact the macro
administrator." & _
vbCrLf & vbCrLf & Err.Number & vbCrLf & " " & Err.Description
Resume ErrExit

End Sub