Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Unload a Form using SelectionChange

I have a Calendar Form that is opened with a SelectionChange. Is there a way
to Unload it with a SelectionChange event? I assume it would have to be in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload a Form using SelectionChange

You could probably use the UserForm Exit event to unload the form.

Private Sub UserForm_Exit()
Unload Me
End Sub

I don't believe it can be incorporated into the SelectionChange.


"Casey" wrote in message
...
I have a Calendar Form that is opened with a SelectionChange. Is there a
way
to Unload it with a SelectionChange event? I assume it would have to be in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Unload a Form using SelectionChange

Thanks for the reply, but the UserForm is automatically dismissed when you
select a date or can be manually closed using the close X. What I'm hoping is
that the Form would unload if you selected any other column besides H, K or
L.
--
Casey




"JLGWhiz" wrote:

You could probably use the UserForm Exit event to unload the form.

Private Sub UserForm_Exit()
Unload Me
End Sub

I don't believe it can be incorporated into the SelectionChange.


"Casey" wrote in message
...
I have a Calendar Form that is opened with a SelectionChange. Is there a
way
to Unload it with a SelectionChange event? I assume it would have to be in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload a Form using SelectionChange

If the UserForm is modal, you cannot select another column. The form would
have to be modeless to make the selection, but I am still trying to
visualize how that could be written into the SelectionChange code, and I
can't.


"Casey" wrote in message
...
Thanks for the reply, but the UserForm is automatically dismissed when you
select a date or can be manually closed using the close X. What I'm hoping
is
that the Form would unload if you selected any other column besides H, K
or
L.
--
Casey




"JLGWhiz" wrote:

You could probably use the UserForm Exit event to unload the form.

Private Sub UserForm_Exit()
Unload Me
End Sub

I don't believe it can be incorporated into the SelectionChange.


"Casey" wrote in message
...
I have a Calendar Form that is opened with a SelectionChange. Is there a
way
to Unload it with a SelectionChange event? I assume it would have to be
in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload a Form using SelectionChange

Well, this worked, but it is not something I would do.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Then
UserForm1.Show vbModeless
Else
Unload UserForm1
End If
End Sub



"Casey" wrote in message
...
Thanks for the reply, but the UserForm is automatically dismissed when you
select a date or can be manually closed using the close X. What I'm hoping
is
that the Form would unload if you selected any other column besides H, K
or
L.
--
Casey




"JLGWhiz" wrote:

You could probably use the UserForm Exit event to unload the form.

Private Sub UserForm_Exit()
Unload Me
End Sub

I don't believe it can be incorporated into the SelectionChange.


"Casey" wrote in message
...
I have a Calendar Form that is opened with a SelectionChange. Is there a
way
to Unload it with a SelectionChange event? I assume it would have to be
in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload a Form using SelectionChange

Since you are calling a subroutine to open the calendar form, you would have
to modify that sub to show the form modeless. Then you will need an If
statement in the SelectionChange sub that only allows the Unload UserForm
statement when there is a form to close. Otherwise, you get an error.


"Casey" wrote in message
...
Thanks for the reply, but the UserForm is automatically dismissed when you
select a date or can be manually closed using the close X. What I'm hoping
is
that the Form would unload if you selected any other column besides H, K
or
L.
--
Casey




"JLGWhiz" wrote:

You could probably use the UserForm Exit event to unload the form.

Private Sub UserForm_Exit()
Unload Me
End Sub

I don't believe it can be incorporated into the SelectionChange.


"Casey" wrote in message
...
I have a Calendar Form that is opened with a SelectionChange. Is there a
way
to Unload it with a SelectionChange event? I assume it would have to be
in
the same subroutine. Here is the current code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("H:H,K:K,L:L")) Is Nothing Then
OpenCalendar
End If

End Sub

--
Casey







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 unload a form Grd Excel Programming 3 March 20th 07 03:48 PM
How to unload a form in excel vba? Edward[_7_] Excel Programming 2 September 30th 04 04:39 PM
Unload the form on esc key Papou Excel Programming 0 August 10th 04 05:15 PM
form won't unload inquirer Excel Programming 1 May 26th 04 09:55 AM
Form Unload Khai[_2_] Excel Programming 0 August 4th 03 09:28 PM


All times are GMT +1. The time now is 09:32 AM.

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"