Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Quit UserForm and Procedure

Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Quit UserForm and Procedure

Maria,

Try this

Private Sub cmdCancel_Click()
Unload Me
End
End Sub

--

HTH

RP

"Maria" wrote in message
...
Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria



  #3   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Quit UserForm and Procedure

IS this also appropriate and is it equivalent


Me.HIDE
Set Userform1 = Nothing

Best N10


"Bob Phillips" wrote in message
...
Maria,

Try this

Private Sub cmdCancel_Click()
Unload Me
End
End Sub

--

HTH

RP

"Maria" wrote in message
...
Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Quit UserForm and Procedure

Hi Bob,

that's it.

Thank you.
Maria

-----Original Message-----
Maria,

Try this

Private Sub cmdCancel_Click()
Unload Me
End
End Sub

--

HTH

RP

"Maria" wrote in

message
...
Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Quit UserForm and Procedure

NO, the code in the calling procedure still continues after this executed.

--

HTH

RP

"N10" wrote in message
...
IS this also appropriate and is it equivalent


Me.HIDE
Set Userform1 = Nothing

Best N10


"Bob Phillips" wrote in message
...
Maria,

Try this

Private Sub cmdCancel_Click()
Unload Me
End
End Sub

--

HTH

RP

"Maria" wrote in message
...
Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Quit UserForm and Procedure

I think I'd use a boolean variable and set/check that:

In a General module:

Dim OkToContinue as boolean
Sub test()
' Some Code
oktocontinue = true
Call UserForm1
if oktocontinue = false then
exit sub
end if
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
oktocontinue = false
Exit Sub
End Sub

The End statement may do more than what you want--if you use global variables,
you'll see that they've been reset.



Maria wrote:

Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Quit UserForm and Procedure

Thanks for the calrification Bob

Best N10

"Bob Phillips" wrote in message
...
NO, the code in the calling procedure still continues after this executed.

--

HTH

RP

"N10" wrote in message
...
IS this also appropriate and is it equivalent


Me.HIDE
Set Userform1 = Nothing

Best N10


"Bob Phillips" wrote in message
...
Maria,

Try this

Private Sub cmdCancel_Click()
Unload Me
End
End Sub

--

HTH

RP

"Maria" wrote in message
...
Hi,

I have a Procedure and a UserForm.
On the UserForm is the Button "Cancel".
When I click this button I would like to quit
the UserForm AND stop running the other procedure.

Sub test()
' Some Code
Call UserForm1
' Some more Code <-- Do not run when quit UserForm
End Sub

Unfortunately this doesn't work:

Private Sub cmbCancel_Click()
Unload Me
Exit Sub
End Sub

What can I do to really leave both?

Thank you for helping me.
Maria








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Opening a UserForm causes a crash in the Exit procedure (Which is never called) Brent McIntyre Excel Programming 0 May 12th 04 12:37 PM
VBA question - calling Procedure from userform ajliaks[_3_] Excel Programming 2 April 14th 04 09:11 PM
Passing Userform as an argument to a procedure Howard Kaikow Excel Programming 12 October 24th 03 03:24 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"