PC Review


Reply
Thread Tools Rate Thread

Display an array in a MsgBox

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      26th Mar 2009
Excel XP & Win XP
I have a variable array that could be ShtArray(a,b,c) or
ShtArray(d,e,f,g,h), etc. The number of elements in the array is also a
variable, as you can see.
In proofing my code I want to find out what array the code selected, so I
used:
MsgBox "ShtArray is: " & ShtArray
which errored out with a "Type Mismatch".
What code would I use to see the elements of the selected array?
I just want to see them at this point. I don't want to do anything with
them.
Thanks for your time. Otto


 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      26th Mar 2009
Hi Otto

You have to create a string with all elements from the array:

Dim MsgString As String
For i = LBound(ShtArray) To UBound(ShtArray)
If MsgString = "" Then
MsgString = ShtArray(i)
Else
MsgString = MsgString & ", " & ShtArray(i)
End If
Next
msg = MsgBox("ShtArray is: " & MsgString)

Regards,
Per

"Otto Moehrbach" <(E-Mail Removed)> skrev i meddelelsen
news:(E-Mail Removed)...
> Excel XP & Win XP
> I have a variable array that could be ShtArray(a,b,c) or
> ShtArray(d,e,f,g,h), etc. The number of elements in the array is also a
> variable, as you can see.
> In proofing my code I want to find out what array the code selected, so I
> used:
> MsgBox "ShtArray is: " & ShtArray
> which errored out with a "Type Mismatch".
> What code would I use to see the elements of the selected array?
> I just want to see them at this point. I don't want to do anything with
> them.
> Thanks for your time. Otto
>


 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      26th Mar 2009
Thank you very much for that. Otto
"Per Jessen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Otto
>
> You have to create a string with all elements from the array:
>
> Dim MsgString As String
> For i = LBound(ShtArray) To UBound(ShtArray)
> If MsgString = "" Then
> MsgString = ShtArray(i)
> Else
> MsgString = MsgString & ", " & ShtArray(i)
> End If
> Next
> msg = MsgBox("ShtArray is: " & MsgString)
>
> Regards,
> Per
>
> "Otto Moehrbach" <(E-Mail Removed)> skrev i meddelelsen
> news:(E-Mail Removed)...
>> Excel XP & Win XP
>> I have a variable array that could be ShtArray(a,b,c) or
>> ShtArray(d,e,f,g,h), etc. The number of elements in the array is also a
>> variable, as you can see.
>> In proofing my code I want to find out what array the code selected, so I
>> used:
>> MsgBox "ShtArray is: " & ShtArray
>> which errored out with a "Type Mismatch".
>> What code would I use to see the elements of the selected array?
>> I just want to see them at this point. I don't want to do anything with
>> them.
>> Thanks for your time. Otto
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MsgBox - Display variable in MsgBox Shiller Microsoft Access VBA Modules 2 29th Sep 2008 10:14 PM
How to display remaining txt file which overflowed MsgBox display? EagleOne Microsoft Excel Misc 1 2nd Nov 2006 01:10 PM
Problem with array and msgbox aking1987 Microsoft Excel Worksheet Functions 0 1st Nov 2004 08:57 AM
Problem with array and msgbox aking1987 Microsoft Excel Worksheet Functions 1 29th Oct 2004 01:57 PM
Problem with array and msgbox aking1987 Microsoft Excel Worksheet Functions 2 28th Oct 2004 06:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:07 PM.