True and False Values in Listbox

mucah!t

Well-known Member
Joined
Jun 27, 2009
Messages
593
Hi all,

The following code initialized data in a listbox on a Userform.
One of the columns in range E5:E1000 contain True and False statements.
In the listbox however they are rendered as 0 and -1.
I need them to be shown as "True" and False".
Is there a way to accomplish this?

Code:
Private Sub UserForm_Initialize()

    Dim lbtarget As MSForms.ListBox
    Dim rngSource As Range
    
     Set rngSource = Sheets("A").Range("E5", Sheets("A").Range("A5").End(xlDown))

     Set lbtarget = Me.ListBox1
    With lbtarget
         .ColumnCount = 5
         .ColumnWidths = "0;40;150;120;50"
        .List = rngSource.Cells.Value
    End With
    
    ListBox1.ListIndex = 0
    
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Sorry -- the group should read:
With lbtarget
.ColumnCount = 5
.ColumnWidths = "0;40;150;120;50"
.RowSource = "=" & rngSource.Address
End With
 
Upvote 0
It looks like you'll have to loop through the range rather than bulk loading the ListBox.
Code:
Private Sub UserForm_Initialize()

    Dim lbtarget As MSForms.ListBox
    Dim rngSource As Range, oneCell as Range
    
     Set rngSource = Sheets("A").Range("E5", Sheets("A").Range("A5").End(xlDown))

     Set lbtarget = Me.ListBox1
     With lbtarget
        .ColumnCount = 5
        .ColumnWidths = "0;40;150;120;50"
        For Each oneCell in rngSouce
            .AddItem CStr(oneCell.Value)
        Next oneCell
    End With
    
    ListBox1.ListIndex = 0
    
End Sub
 
Upvote 0
Hello guys, thanks for your suggestions, but neither worked.
mikerickson's results in an empty listbox.
 
Upvote 0
I still haven't found a solution for this problem.
Perhaps you'd like to take a look at it.
I stored a sample-file of it here
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top