Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cancel Button on Userform

Hi everyone.
I am trying to put together an application that formats and calculates raw
data in a spreadsheet.
I have created a Userform with a multipage control that loads in before all
the work on the data is performed, asking the user to confirm if it is the
right formatting and requests a couple of entries that I gather via Text
boxes that are needed for later comparison. Everything works fine except for
the Cancel-button.
I use the standard code in the userform-code-module:

Sub CancelButton_Click()
Unload Me
End Sub

The problem now is that the userform is unloaded, but the sub continues to
do all the formatting and calculations which I want to avoid. I would like
the sub to end completely if the user clicks the cancel button.
Any ideas or suggestions?

Thanks very much.

Knut Dahl


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Cancel Button on Userform

Publie bStop as Boolean

Sub Main()
Userform1.Show
if bStop then Exit sub
' other code
end Sub


Sub CancelButton_Click()
bStop = True
Unload Me
End Sub

--
Regards,
Tom Ogilvy


"KJ Dahl" wrote in message
...
Hi everyone.
I am trying to put together an application that formats and calculates raw
data in a spreadsheet.
I have created a Userform with a multipage control that loads in before

all
the work on the data is performed, asking the user to confirm if it is the
right formatting and requests a couple of entries that I gather via Text
boxes that are needed for later comparison. Everything works fine except

for
the Cancel-button.
I use the standard code in the userform-code-module:

Sub CancelButton_Click()
Unload Me
End Sub

The problem now is that the userform is unloaded, but the sub continues to
do all the formatting and calculations which I want to avoid. I would like
the sub to end completely if the user clicks the cancel button.
Any ideas or suggestions?

Thanks very much.

Knut Dahl




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cancel Button on Userform

Great stuff, thanks
You won't believe the stuff I tried and it turns out to be quite an easy
snippet of code.

Thanks again
"Tom Ogilvy" wrote in message
...
Publie bStop as Boolean

Sub Main()
Userform1.Show
if bStop then Exit sub
' other code
end Sub


Sub CancelButton_Click()
bStop = True
Unload Me
End Sub

--
Regards,
Tom Ogilvy


"KJ Dahl" wrote in message
...
Hi everyone.
I am trying to put together an application that formats and calculates
raw
data in a spreadsheet.
I have created a Userform with a multipage control that loads in before

all
the work on the data is performed, asking the user to confirm if it is
the
right formatting and requests a couple of entries that I gather via Text
boxes that are needed for later comparison. Everything works fine except

for
the Cancel-button.
I use the standard code in the userform-code-module:

Sub CancelButton_Click()
Unload Me
End Sub

The problem now is that the userform is unloaded, but the sub continues
to
do all the formatting and calculations which I want to avoid. I would
like
the sub to end completely if the user clicks the cancel button.
Any ideas or suggestions?

Thanks very much.

Knut Dahl






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
How to get userform Cancel button to invoke Exit Sub in calling macro? Craig Remillard New Users to Excel 1 November 19th 09 03:55 AM
Cancel button IamHaxer Excel Programming 3 June 24th 04 05:19 PM
Inputbox and cancel button Uddinj1 Excel Programming 5 March 2nd 04 11:27 AM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM
input box cancel button Ian Mangelsdorf Excel Programming 1 August 28th 03 09:05 PM


All times are GMT +1. The time now is 10:03 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"