Aligning values in a form listbox?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
271
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a form with a listbox which is populated by some SQL code, typically:
VBA Code:
rs.MoveFirst
i = 0
With Me.ListBox1
    .Clear
    .ColumnWidths = "210;50;120;110;100;64;75;46;45;45"
    Do
        .AddItem
        .List(i, 0) = rs![Practice]
        .List(i, 1) = rs![TotalDocCount]
        .List(i, 2) = Format(rs![TotalDocValue], "#,##0.00;(#,##0.00)")
        .List(i, 3) = rs![RetroDocCount]
        .List(i, 4) = Format(rs![RetroDocValue], "#,##0.00;(#,##0.00)")
        .List(i, 5) = rs![NonRetroDocCount]
        .List(i, 6) = Format(rs![NonRetroDocValue], "#,##0.00;(#,##0.00)")
        .List(i, 7) = rs![Less1k]
        .List(i, 8) = rs![Onekto5k]
        .List(i, 9) = rs![Fivekto10k] + rs![Tenkplus]
       ' .List(i, 10) = rs![Tenkplus]
        i = i + 1
        rs.MoveNext
    Loop Until rs.EOF
End With

This works perfectly except for the alignment of the numbers in several of the columns. They appear like this
Code:
0.00
79.34
131.23

whereas I'd like them to look like
Code:
  0.00
 79.34
131.23

Can I align them or is this a limitation of using a listbox?

Many thanks.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,772
Messages
6,126,814
Members
449,339
Latest member
Cap N

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