Unload a UserForm

  • Thread starter Thread starter Patrick C. Simonds
  • Start date Start date
What does current range is B5 mean, and what does that have to do with a
userform?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Okay

The short version is I need something like:

If cell B5 is active Unload Me

The long an I am afraid convoluted explanation is below:

I have a Userform for each month of the year (which in my original posting I
referred to as UserForm1) all twelve of these UserForms has a button which
loads UserForm2 (while leaving it's self loaded) which has a Yes and a No
button on it.

If they click on Yes, a routine runs to delete some data and then selects
cell B5 of the active worksheet. If they select No UserForm2 closes and you
can make another selection on the month UserForm. UserForm2 is nothing more
than a last chance to back out before deleting the data.

Since all twelve of the monthly UserForms are using UserForm2 I need some
way to close the Monthly UserForm after the delete routine had run. So I
thought I could add an If statement to the UserForm which loaded UserForm2
that would close the Monthly UserForm. Something that like :
 
Okay

The short version is I need something like:

If cell B5 is active Unload Me

The long an I am afraid convoluted explanation is below:

I have a Userform for each month of the year (which in my original posting I
referred to as UserForm1) all twelve of these UserForms has a button which
loads UserForm2 (while leaving it's self loaded) which has a Yes and a No
button on it.

If they click on Yes, a routine runs to delete some data and then selects
cell B5 of the active worksheet. If they select No UserForm2 closes and you
can make another selection on the month UserForm. UserForm2 is nothing more
than a last chance to back out before deleting the data.

Since all twelve of the monthly UserForms are using UserForm2 I need some
way to close the Monthly UserForm after the delete routine had run. So I
thought I could add an If statement to the Month UserForm which loaded
UserForm2
that would close the Monthly UserForm.
 
Figured it out:

If ActiveCell = Range("B5") Then
Unload Me
End If
 
This uses the default property of both ranges.

It's equivalent to:

if activecell.value = range("b5").value then

So if those cells contain the same thing (or are both empty), you may not want
this....

I'd use
if activecell.address = range("b5").address then
or
if activecell.address = "$B$5" then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Userform 3
Unload UserForms 9
Unloading userforms 6
Userform 3
Firing Event in another user form 1
listbox click event question 4
Unload Userform doesn't work here - why? 1
Auto closing UserForm 3

Back
Top