Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

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

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Singapore
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ?

  2. #2
    MrExcel MVP lenze's Avatar
    Join Date
    Feb 2002
    Location
    Helena, MT
    Posts
    13,690
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Singapore
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Singapore
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •