Userform: Tie Listbox Items and Label vertical position

wist

Board Regular
Joined
Nov 8, 2012
Messages
79
Hai,

I have a userform which is driving me crazy. It has a ListBox with a bunch of items and next to it labels that give info about the listbox items but they do not alight properly when I have too many items. I can't figure out how to tie them together or at least make it look like so:
znkHpNN


Couple of items look just fine: https://ibb.co/znkHpNN

But a lot of items don't align anymore: https://ibb.co/cDywFnY

This is the part of the code I used for labels but it seems when I use decimal places for .Top property it doesn't do what I need. For example 4.2 adds more spacing than 4.5, any idea why?
Code:
       With textUSD
            .Name = "USD" & i
            .Caption = Format(Round(wb.Sheets(1).Cells(i + 1, 1).Value, 2), "standard")
            .TextAlign = fmTextAlignCenter
[B]            .Top = 4.5 + j[/B]
            .Left = -5
        End With
        
        With checks
            .Name = "Check" & i
            .Caption = wb.Sheets(1).Cells(i + 1, 2).Value
            .Font.Name = "Wingdings 2"
            .Font.Charset = 2
            .Font.Size = 11
         If .Caption = "O" Then .ForeColor = RGB(255, 0, 0) Else .ForeColor = RGB(0, 176, 80)
            .TextAlign = fmTextAlignCenter
[B]            .Top = 4.5 + j[/B]
            .Left = -18
        End With

j = j + 9.5
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I don't know how to do that, but just a thought, why not use another 2 listbox to show all the labels & the check mark? so it can be aligned easily.
 
Upvote 0
I don't know how to do that, but just a thought, why not use another 2 listbox to show all the labels & the check mark? so it can be aligned easily.

that's not a bad idea at all ...I can just modify the new listbox so there are no borders and insert it into the frame just as I have now ...thanks Akuini

It's not super elegant so if anyone has a better idea I'm all eyes :)
 
Upvote 0
OK, I have the first listbox aligned but the one with Checks is not aligned because the Font is different :((
 
Upvote 0
The check mark is in the third listbox, right?
How do you populate it to the listbox? Using AddItem?
What font are you using?
 
Upvote 0
The check mark is in the third listbox, right?
How do you populate it to the listbox? Using AddItem?
What font are you using?

your listboxes look quite neat, yes I am using AddItem ...what code or font did you use for the check marks ?

Code:
       With ZeroBox           
            .AddItem wb.Sheets(1).Cells(i + 1, 2).Value
            .Font.Name = "Wingdings 2"
            .Font.Charset = 2
            .Locked = True
            .Font.Size = 11
        End With

sadly I also wanted to have checkmarks green and eXes red but that's not possible with the listbox I think
 
Last edited:
Upvote 0
your listboxes look quite neat, yes I am using AddItem ...what code or font did you use for the check marks ?
Using this:

Code:
For i = 1 To 40
ListBox3.AddItem ChrW(&H2713)
Next

sadly I also wanted to have checkmarks green and eXes red but that's not possible with the listbox I think
No, I don't think it possible.
 
Upvote 0
Thanks again Akuini this works great now if I could just make the crosses red and checks green :P
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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