Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default range not carrying over

On Nov 26, 8:25 am, Dave Peterson wrote:
If your other code unloads the userform, then maybe just hiding the userform
would be enough.

Private Sub btnCancel_Click()
me.hide
End Sub


But it's just a guess.


I'll give that a try next week, when I'm back at the office. Can you
tell me what's wrong with using "End" as I've done? Obviously,
there's some reason why you're steering me away from that. But it
seems to me that if I hide the form, but the user hasn't filled it in,
that I'll have the same problem with undefined variables if I just
hide the form, when the remaining code runs. Since "End" is working ok
in this instance, there's got to be a particular reason why you feel
it's not good practice. You mentioned earlier that it would "reset the
variables". I'm not sure what that means, but since the routine is
ending, does it matter? Or is this a "bad practice" that will cause me
problems in some other situation? Can you elaborate?



davegb wrote:

On Nov 21, 12:03 pm, Dave Peterson wrote:
There was no following code.


By following code, I meant the code that runs after the form is
closed. When it tried to run, since none of the variables that were
defined by the user filling in the userform, I was geting an undefined
variable error. So the Cancel button has to not just close the
userform, but stop running the other code.


Thanks again for all your help.


davegb wrote:


On Nov 20, 8:14 am, davegb wrote:
On Nov 19, 12:26 pm, Dave Peterson wrote:


#2. Maybe you could just unload the form.


Private Sub btnCancel_Click()
unload me
End Sub


I modified the code to try this. I remember I found this in this NG
some time ago and tried it, but it didn't recognize "Me" and I had to
replace it with the userform name to get it to work. Never figured out
why. Can't test it until I figure out why I'm getting the compile
error in the General module.


I made this change but it caused problems. When I just close the form,
the following code tries to execute but since the userform data is not
there, I get undefined variable errors. Is there a better way of
handling all this? For now, to work on the program, I just put back
the End statement.


#1. Difficult to guess without seeing what changes you made.


Of course. I prefer to work on a problem for a while before I post
here. I learn more that way and actually get to write some code. I
appreciate you experts taking the time to help me out here, but I
prefer not to bother you until I'm stumped. Thanks again for all your
help.


Found the problem and fixed it.


davegb wrote:


On Nov 16, 4:31 pm, Dave Peterson wrote:
<<snipped


Dave, thanks for your reply.
I moved the public declarations from the userform module to the
general module. Now I'm getting a compile error on one of the
variables that I wasn't getting before. Not sure why, but I'm trying
to track it down.


As for the Button Cancel routine resetting my variables, I didn't know
it did that, but I don't think it matters. I just wanted to end the
whole routine if the user chooses "Cancel". If there's a better way,
I'm all ears, like Prince Charles! :)


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--

Dave Peterson


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
Carrying last $$$ amount to another field Challenged Excel Worksheet Functions 4 April 13th 09 07:01 AM
Carrying data over in worksheets roxiemayfield Excel Worksheet Functions 4 December 5th 07 10:00 PM
Carrying a balance forward Melanie Savasta Excel Worksheet Functions 2 April 18th 06 04:07 PM
Carrying formatting automatically to new W/S Jonah Excel Worksheet Functions 4 September 6th 05 12:12 AM
IF is not carrying out the FALSE part derekbrown Excel Worksheet Functions 3 August 23rd 05 11:28 AM


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

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

About Us

"It's about Microsoft Excel"