ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   On Error GoTo Doesn't Work (https://www.excelbanter.com/excel-discussion-misc-queries/167882-error-goto-doesnt-work.html)

[email protected]

On Error GoTo Doesn't Work
 
When the active cell doesn't have a Reference Name the "On Error GoTo
ExitMe" does not trigger but instead I get the runtime error 1004.
Could you please tell me what I am doing wrong? Thanks-

Private Sub CancelButton_Click()
Me.Hide
End Sub

Private Sub OKButton_Click()
Me.Hide
End Sub

Private Sub UserForm_Activate()
On Error GoTo ExitMe
TextBox1.Text = ActiveCell.Name.Name
GoTo Done
ExitMe:
TextBox1.Text = "Sorry this cell does not have a refrence name"
Done:
End Sub

Dave Peterson

On Error GoTo Doesn't Work
 
Inside the VBE with your workbook's project selected:

Tools|Options|General tab
change the error trapping from "break on all errors" to "break in class module"

wrote:

When the active cell doesn't have a Reference Name the "On Error GoTo
ExitMe" does not trigger but instead I get the runtime error 1004.
Could you please tell me what I am doing wrong? Thanks-

Private Sub CancelButton_Click()
Me.Hide
End Sub

Private Sub OKButton_Click()
Me.Hide
End Sub

Private Sub UserForm_Activate()
On Error GoTo ExitMe
TextBox1.Text = ActiveCell.Name.Name
GoTo Done
ExitMe:
TextBox1.Text = "Sorry this cell does not have a refrence name"
Done:
End Sub


--

Dave Peterson

[email protected]

On Error GoTo Doesn't Work
 
Thanks Dave You da MAN!!! :-)


All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com