Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compile Error
Need End If after
If ActiveWorkbook.Sheets.Count 2 Then intSheet = InputBox("Enter sheet number to return to:", "Sheet Number", 2) "Sprinks" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compile Error
You're missing an End If to sync up with
If ActiveWorkbook.Sheets.Count 2 Then -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Sprinks" wrote in message ... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Compile Error
Thanks, Charlie and Chip.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
help with this error-Compile error: cant find project or library | Excel Discussion (Misc queries) | |||
VBAProject name compile error, not defined at compile time | Excel Programming | |||
error message: compile error, argument not optional | Excel Programming | |||
How do I get rid of "Compile error in hidden module" error message | Excel Discussion (Misc queries) |