ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unload a UserForm (https://www.excelbanter.com/excel-programming/415682-unload-userform.html)

Patrick C. Simonds

Unload a UserForm
 
How can I Unload UserForm1 if the current range is B5?

Bob Phillips

Unload a UserForm
 
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)

"Patrick C. Simonds" wrote in message
...
How can I Unload UserForm1 if the current range is B5?




Patrick C. Simonds

Unload a UserForm
 
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 :



"Bob Phillips" wrote in message
...
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)

"Patrick C. Simonds" wrote in message
...
How can I Unload UserForm1 if the current range is B5?





Patrick C. Simonds

Unload a UserForm
 
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.



"Bob Phillips" wrote in message
...
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)

"Patrick C. Simonds" wrote in message
...
How can I Unload UserForm1 if the current range is B5?





Patrick C. Simonds

Unload a UserForm
 
Figured it out:

If ActiveCell = Range("B5") Then
Unload Me
End If



"Patrick C. Simonds" wrote in message
...
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.



"Bob Phillips" wrote in message
...
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)

"Patrick C. Simonds" wrote in message
...
How can I Unload UserForm1 if the current range is B5?






Dave Peterson

Unload a UserForm
 
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



"Patrick C. Simonds" wrote:

Figured it out:

If ActiveCell = Range("B5") Then
Unload Me
End If

"Patrick C. Simonds" wrote in message
...
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.



"Bob Phillips" wrote in message
...
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)

"Patrick C. Simonds" wrote in message
...
How can I Unload UserForm1 if the current range is B5?




--

Dave Peterson


All times are GMT +1. The time now is 12:00 AM.

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