Link to home
Start Free TrialLog in
Avatar of david francisco
david franciscoFlag for United States of America

asked on

Display Multiple Cells in TextBox

I have a text box that I need to display multiple cells of data. For instance my data is:

Red | 5
Blue | 6
Green |12
Purple |11

and I need it to display this data in the same general format, but with the code I have now it only displays:

Red | 5

The code I have is
Me.TextBox4.Value = ""

    Dim rngName As Range
    Dim ws As Worksheet
    Dim i As Integer

    Set ws = Worksheets("FUN")
    For i = 1 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
        If ws.Cells(i, 1).Value <> vbNullString Then
            Dim tempVal As String
            tempVal = ws.Cells(i, 1).Value & "                         " & ws.Cells(i, 2).Value
            Me.TextBox4.Text = tempVal
        End If
    Next i

Open in new window

Avatar of david francisco
david francisco
Flag of United States of America image

ASKER

I should clarify, this is a textbox, not a listbox.
SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial