+ Reply to Thread
Results 1 to 11 of 11

Why msgbox is not appearing and why items aren't being removed?

  1. #1
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Unhappy Why msgbox is not appearing and why items aren't being removed?

    Many problems have appeared in my form.

    1. I put some "msgbox" to test it. When I run the first time they appear. When I click to open the form again, the messages simply disappear, even though I had written msgbox "why??" in the first line of code.

    2. We created a code to remove empty items from the combobox, but they just aren't excluded. They asked that I reversed the "for", to start from the bottom up. Didn't solve.

    3. The program is unable to calculate the minimum and the average of a range, although the code is correct.

    Someone, please, would be able to help me?
    Attached Files Attached Files
    Last edited by marlonsaveri; 04-03-2011 at 12:43 PM. Reason: I've disrespected the first rule of the forum: the title was incorrect.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Please, my form is crazy!

    Hi marlonsaveri

    I think the problem is that you are not doing an UNLOAD ME on your userform when you close it. This will keep the Userform in memory and it won't execute the Initialize code if it is already in memroy.

    You need to study Userform.Show, Userform.Hide and Unload Me.

    Change the code you have by adding the Unload Me line below and see if this works for you.

    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Please, my form is crazy!

    Thanks so much, maybe it solves the fist doubt. However, tha blanks remains.

    I was thinking ".hide" and "unload myuserform" was the same. Thanks, it really shows the difference.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Please, my form is crazy!

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Marvin, as a regular poster I'm surprised that you answered this question that so obviously did not comply with the Forum Rules
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Why msgbox is not appearing and why items aren't being removed?

    Sorry, I've forgotten the rule. It's aready fixed.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Why msgbox is not appearing and why items aren't being removed?

    Hi,
    Try this to get rid of blanks in the combo box. Replace your code with.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114

    Re: Why msgbox is not appearing and why items aren't being removed?

    Hi,

    This should solve #2 & #3.

    Tony
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Thumbs up Re: Why msgbox is not appearing and why items aren't being removed?

    I adore the solidarity of internet. Thanks TonyS, MarvinP and RoyUK.
    Even when they think excel is're crazy, you have a possible fix.


    The samplefile is ok. However, I did not understand why it's not showing average, max and min on original workbook. Hence, I made a small change and it worked:

    Please Login or Register  to view this content.
    Just a last problem: labels don't show decimal numbers when I do it, just entire numbers.

  9. #9
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Why msgbox is not appearing and why items aren't being removed?

    I don't have idea why, but "WorksheetFunction.Average" works just some times. And, when it not works; even though appears a msgbox "Sorry, error", it opens VBA programming page with a 1004 Error (the user shouldn't see it, or he could change something, what is dangerous).

    1004 error: It is not possible get Average property from WorksheetFunction

    I've thought when we use "On Error goto StudyError" it wouldn't happen

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Why msgbox is not appearing and why items aren't being removed?

    Hi Marlin,

    Maybe your "myRange" isn't defined or has things in it that can't be averaged. If and when your program stops with the error you should look to see where myRange is pointing and look at each of the cells to see if this is causing the problem. If these aren't cells but in the UserForm, check to see if the userform is open/in memory and has values.

    You should also learn to Debug your code using Breakpoints and Stepping through the code which might also uncover the problem. see http://www.cpearson.com/excel/Debug.htm

  11. #11
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Why msgbox is not appearing and why items aren't being removed?

    MyRange is a range of cells.
    Debugging, the error is sometimes in "average", sometimes in "max, min and average". Error 5 or Error 1004. Error because some cell in "MyRange" has letters or characters or when all cells in "MyRange" are empty.

    I changed max, min and av to "string" and I've used "Val(max)", the code was not better.

    So, one said to don't use worksheetfunctions. However, if I try something like:
    Please Login or Register  to view this content.
    However, it doesn't solve the problem of it has letters or other characters.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1