UserForm1.Hide is not just to hide UserForm1 ????

Andrew XJ

Board Regular
Joined
Feb 21, 2002
Messages
77
Please help me out in this frustrating problem. All this in one workbook with a Auto_Run(). In Auto_Run() i use UserForm1.Show to load and show UserForm1. In UserForm1_initialize(), UserForm1.Show is one of the statements.
In the UserForm1, there is a command button associated with a statement UserForm1.Hide.

The problem is that: When i click the HideUserForm button, an error message pops out "Subscript out of Range". And after i click "debug", the line "UserForm1.Show" in Auto_Run() is highlighted!!!! How come!!!! The click of HideUserForm button just activate one statement UserForm1.Hide......What happens here? UserForm1.Hide is not just to set Visible to False as stated in VBA help, is it???
Could you enlight what happens after UserForm1.Hide on earth? And how about UserForm.Show ?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I'm not sure if this is the problem, but you might try using Load Userform1 and Unload Userform1 instead of Show and Hide which are really only toggles.
 
Upvote 0
But Can't use Load method.
Sorry, i haven't described the problem exactly. I tested that again. and the error message is "Run time error 5, Invalid procedure call or property".
The highlighted line is "UserForm1.Show" in Auto_Run(). But if i click "continue" button or press F5, the UserForm appears again, while the error message pops up again when i click the button to hide the UserForm.

When i change UserForm1.Show to Load UserForm1 in Auto_Run, the same error message appears.
In fact i feel that everytime UserForm1.Show runs, the UserForm1_Initialize() will run!!!


best regards
Andrew XJ
 
Upvote 0
Parts of my code get problem: ( in UserForm1_initialization)
UserForm1.Controls("ComboBox1").SetFocus
With UserForm1.Controls("ComboBox1")
.RowSource = "X1:X" & lastRowInSheet1
.Text = Range("X1").Value
sgBox "row source first time set"
Do While (IsParamDirty(.Text))
rowToDelete = Range("X1:X" & _ lastRowInSheet1).Find(what:=.Text, _ LookIn:=xlValues, lookat:=xlWhole, _
SearchOrder:=xlByColumns,MatchCase:=False).Row
Range("X" & rowToDelete & ":Z" & _ rowToDelete).Delete shift:=xlShiftUp

If (Trim(Range("X1").Text)<> vbNullString) Then
lastRowInSheet1 = lastRowInSheet1 - 1
End If
.Text = Range("X" & lastRowInSheet1).Value
Loop
.RowSource = "X1:X" & lastRowInSheet1
End With

This part of code doesn't work.
Is there any difference whether i use .Text or or use .Value? previously i use .Value.


best regards
Andrew XJ
This message was edited by Andrew XJ on 2002-03-18 07:54
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,988
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top