Consulting

Results 1 to 3 of 3

Thread: Solved: Display items of a collection in a message box?

  1. #1
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location

    Solved: Display items of a collection in a message box?

    Hi all, currently i am creating collections to fill comboboxes for viewing purposes, however, i really would rather show them on a message box but it doesn't accept a collection anyone know how to do it?
    The variables have been declared as collections.
    [vba]For Each Cel In rng
    Select Case LCase(Cel.Value)
    Case "Ms": Msa.Add Cells(1, Cel.Column).Value, CStr(Cells(1, Cel.Column).Value)
    Case "Ks": Ksa.Add Cells(1, Cel.Column).Value, CStr(Cells(1, Cel.Column).Value)
    Case "Ds": Dsa.Add Cells(1, Cel.Column).Value, CStr(Cells(1, Cel.Column).Value)
    Case "Os": Osa.Add Cells(1, Cel.Column).Value, CStr(Cells(1, Cel.Column).Value)
    Case "Ts": Tsa.Add Cells(1, Cel.Column).Value, CStr(Cells(1, Cel.Column).Value)
    End Select
    Next Cel[/vba]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I dson't see any collections there!

    [vba]

    For Each colval In mycoll

    msg = msg & colval & vbNewLine
    Next colval
    MsgBox msg
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Thanks Bob, i just quickly adapted the code i posted from my userform, it's still early yet!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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