Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Unload UserForms

Hi,

I am looking for a way to unload UserForms. I can unload one, but need all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"), xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload UserForms

I assume you meant if vbOK is selected since the MsgBox has vbOKCancel.
Give this a try. Post back if there is a problem.

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"), xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = 1 To UserForms.Count
Unload UserForm(i)
Next
End If

End Sub




"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload UserForms

Might work better this way.

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForm(i)
Next
End If

End Sub




"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



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

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Unload UserForms

My apologies for tardiness....had 'man flu' only just recovered.......

am getting error at: Unload UserForms(i) point in code that you posted

Any ideas?

Craig

"JLGWhiz" wrote:

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



.



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

Try changing this line:

For i = UserForms.Count To 1 Step -1

To this:

For i = UserForms.Couint - 1 To 0 Step = -1




"Craig" wrote in message
...
My apologies for tardiness....had 'man flu' only just recovered.......

am getting error at: Unload UserForms(i) point in code that you posted

Any ideas?

Craig

"JLGWhiz" wrote:

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload UserForms

Just a note that your UserForms must be loaded as ShowModal = False for the
code to work.


"Craig" wrote in message
...
My apologies for tardiness....had 'man flu' only just recovered.......

am getting error at: Unload UserForms(i) point in code that you posted

Any ideas?

Craig

"JLGWhiz" wrote:

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig



.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Unload UserForms

Sorry, dont get that bit:

To show UF1:

Private Sub CommandButton6_Click()
UserForm5.Show
End Sub

Then press button for sort options and code behind that is:

Private Sub CommandButton3_Click()

Worksheets("Issues").Visible = True
Worksheets("Issues").Select
Range("A1").Activate

Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"), xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count - 1 To 0 Step = -1
Unload UserForms(i)
Next
End If
End Sub

Dont understand where to put the Modal bit?

Sorry, dont think Man Flu completely gone !!

"JLGWhiz" wrote:

Just a note that your UserForms must be loaded as ShowModal = False for the
code to work.


"Craig" wrote in message
...
My apologies for tardiness....had 'man flu' only just recovered.......

am getting error at: Unload UserForms(i) point in code that you posted

Any ideas?

Craig

"JLGWhiz" wrote:

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig


.



.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Unload UserForms

Maybe I have misunderstood your original post. I thought that you had more
than one userform opened at once and wanted to know how to unload them in
one command. If you only wanted to unload one UserForm then you do not need
the For ... Next loop statement, You can just:

Unload UserForm5 ' or whaterver name it is

To explain the Modal part. The default condition to load a UserForm is
Modal. This condition stops all other events except those controlled by the
UserForm until the UserForm is unloaded. In this condition, only one
UserForm can be loaded at a time. To load more than one UserForm, the
UserForm#.Show ShowModal:=False must be used to load the form in what is
commonly referred to as a modeless condition. More than one UserForm can be
loaded at a time using this method. It was the second method that I had
though you were using, but apparently not. My error, I should have asked
long ago.

"Craig" wrote in message
...
Sorry, dont get that bit:

To show UF1:

Private Sub CommandButton6_Click()
UserForm5.Show
End Sub

Then press button for sort options and code behind that is:

Private Sub CommandButton3_Click()

Worksheets("Issues").Visible = True
Worksheets("Issues").Select
Range("A1").Activate

Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green", vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count - 1 To 0 Step = -1
Unload UserForms(i)
Next
End If
End Sub

Dont understand where to put the Modal bit?

Sorry, dont think Man Flu completely gone !!

"JLGWhiz" wrote:

Just a note that your UserForms must be loaded as ShowModal = False for
the
code to work.


"Craig" wrote in message
...
My apologies for tardiness....had 'man flu' only just recovered.......

am getting error at: Unload UserForms(i) point in code that you posted

Any ideas?

Craig

"JLGWhiz" wrote:

I am having one of those nights:

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
For i = UserForms.Count To 1 Step -1
Unload UserForms(i)
Next
End If

This corrects the syntax for a collection item.


"Craig" wrote in message
...
Hi,

I am looking for a way to unload UserForms. I can unload one, but
need
all
others to unload if vbYes is selected:

Code used is:

Private Sub CommandButton1_Click()
Range("A5:D50", Range("A5:D50").End(xlDown)).sort Range("B50"),
xlAscending

Dim Res As VbMsgBoxResult
Res = MsgBox("This will sort data into Red, Amber & Green",
vbOKCancel)
If Res = vbOK Then
Unload UserForm5
End If

End Sub

UserForm1 is selected prior to UserForm5 as sort is an option on UF5

Any help gratefully received

Many Thanks

Craig


.



.



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
unload vs hide userforms randy Excel Programming 2 May 29th 08 02:17 PM
Getting error with load/unload of UserForms?? Ed from AZ Excel Programming 2 August 22nd 07 04:21 PM
unload an add-in from an Macro lang0477[_2_] Excel Programming 4 June 3rd 05 03:54 AM
Excel Won't Unload... Steven8R Excel Programming 3 October 20th 04 04:42 AM
Unload Me Chip Pearson Excel Programming 0 September 5th 03 12:56 AM


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