Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Show values of Array Elements in a MsgBox

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is this possible? As my code goes through a worksheet looking for problems, I would like to collect the information in an array. At the end, I want a single MsgBox to show all of the values (elements) in the array.

  2. #2
    MrExcel MVP Damon Ostrander's Avatar
    Join Date
    Feb 2002
    Location
    Denver, Colorado USA
    Posts
    4,239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Tim,

    Yes, you can easily do this. Just concatenate the text you want to display for each item onto the previous text, putting a linefeed-carriage return between each. For example, say you have an account number that is a text string that you want to put in the array every time a problem occurs with that account, and that account number is in a string variable named AcctNo. Define another string variable MsgArray. Each time a problem occurs, add it to the MsgArray string:

    MsgArray = MsgArray & vbCrLf & AcctNo

    Now at the end of the program display the message:

    MsgBox MsgArray, _
    vbExclamation, _
    "Problem Account List"


    Keep Excelling.

    Damon

    VBAexpert Excel Consulting
    LinkedIn Profile http://www.linkedin.com/pub/damon-ostrander/7/79/a93
    AllExperts Profile http://www.allexperts.com/ep/1059-30...-Ostrander.htm

  3. #3
    New Member
    Join Date
    Nov 2011
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Show values of Array Elements in a MsgBox

    found the solution:

    If search_results Is Nothing Then
    ...

    End if

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
  •