+ Reply to Thread
Results 1 to 6 of 6

MsgBox does not appear after the code executes.

Hybrid View

  1. #1
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Smile MsgBox does not appear after the code executes.

    Hi
    I have a code, which works, but I want msgbox appear after the code executes. But it does not. Why?

    Private Sub CommandButton7_Click() 'Code is not working
    Dim intIndex As Integer, intCount As Integer, i As Integer, ListRow As Integer
    Application.ScreenUpdating = False
    On Error GoTo oops
        For intIndex = 0 To ListBox1.ListCount - 1 'Counts how many items in listbox.1 selected
            If ListBox1.Selected(intIndex) Then intCount = intCount + 1
        Next intIndex
    
        For ListRow = 1 To 40 'Hides corresponding buttons
            If ListBox1.Selected(ListRow) Then
                ActiveSheet.Shapes(Application.WorksheetFunction.Index(Range("ButtonName"), _
                    Application.WorksheetFunction.Match(ListBox1.List(ListRow), _
                ActiveSheet.Range("Source"), 0))).Visible = False
            End If
        Next ListRow
        MsgBox "DONE!!!!!!!!!!!!!" 'HERE HERE HERE NOT APPEARING
    oops:
    Unload Me
    End Sub
    Attached Files Attached Files
    Last edited by contaminated; 01-05-2010 at 07:51 AM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446

    Re: MsgBox does not appear after the code executes.

    Just a wild stab in the dark, but do you need Screenupdating turned on to display a messgae box?

    Dave

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: MsgBox does not appear after the code executes.

    Is your code ever getting to that line or is it erroring out thus skipping to your Unload Me line? Just plonk a message box after oops indicating if an error was made:

    oops:
      If Err<>0 Then MsgBox "An error occured"
      Unload Me
      End Sub
    Richard Schollar
    Microsoft MVP - Excel

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,447

    Re: MsgBox does not appear after the code executes.

    Listboxes are zero based.
    You are trying to access item 40, which does not exists.

        For ListRow = 0 To ListBox1.ListCount - 1 'Hides corresponding buttons
    Always a good idea when code with Error trapping is not working is to remove the error trapping in order to see the actual error. Put it back when reason is understood and resolved.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: MsgBox does not appear after the code executes.

    Hi sweep
    Thx for responce
    Actually I dont need screenupdating at all.

  6. #6
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: MsgBox does not appear after the code executes.

    Thank u for all your responces
    RichardSchollar
    Workde like a charm!!!!!!!!!!!!!

+ 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