![]() |
Macro Exit or Link
I am creating a macro that when someone agrees the macro will take someone to
the home page, if they say no, then a message will come up "saying something" and will exit from the workbook. This is what i have so far: Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = True If Target.Address = "$C$15" Then If Me.Range("C15").Value = "Yes" Then Worksheets("Home").Range "F8" End If If Me.Range("C15").Value = "No" Then ThisWorkbook Application.Quit End If End If ws_exit: Application.EnableEvents = True End Sub Can someone assist me? Thank you, Dan |
Macro Exit or Link
First I think you want to use the Worksheet_Change event not
Worksheet_SelectionChange. Then you want to disable events inititally, not enabled them (they are enabled or this sub would not be called). Then for the go to you'd want this: Application.Goto Worksheets("Home").Range("F8") Also drop the ThisWorkbook before Application.Quit. The latter is all you need. You might want to add a ThisWorkbook.Saved = True before quiting so there is no "save changes" prompt. Jim "Daniel R. Young" wrote in message ... I am creating a macro that when someone agrees the macro will take someone to the home page, if they say no, then a message will come up "saying something" and will exit from the workbook. This is what i have so far: Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = True If Target.Address = "$C$15" Then If Me.Range("C15").Value = "Yes" Then Worksheets("Home").Range "F8" End If If Me.Range("C15").Value = "No" Then ThisWorkbook Application.Quit End If End If ws_exit: Application.EnableEvents = True End Sub Can someone assist me? Thank you, Dan |
All times are GMT +1. The time now is 03:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com