Setting tabstrip to fit multi column listbox

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,099
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
My Form uses tabstrip above a multi column listbox.
The width of each tab is (I think) determined by the caption size.
My goal is to set the tabs to the same widths as the list columns, irrespective of the captions.
If I'm correct the captions would need padding. The Font is Tahoma Bold 9

Does anyone have any suggestions how best to do this?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Something like this maybe? It might take a bit of trial and error with the space padding and widths as there doesn't seem to be a lot of control over the tab widths in a tabstrip other than through the caption, but someone else may know of a way.

VBA Code:
Private Sub UserForm_Initialize()
    With Me.ListBox1
        .Width = 290
        .ColumnHeads = True
        .ColumnCount = 2
        .ColumnWidths = "3 cm;7cm"
    End With
    With Me.TabStrip1
        .Width = 290
        .Tabs(0).Caption = Space(10) & "Longer caption"
        .Tabs(1).Caption = Space(77) & "x"
    End With
End Sub

1722495695686.png
 
Upvote 0
Thanks for the ideas. I think it was a big ask, as you've confirmed, you can only set the width fore the whole tabstrip.The tab captions vary too. My only solution may be to adjust manually and hard code the widths for each. Knowing the column widths doesn't help.
I'm trying this out out but open to any other suggestions.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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