Listbox columns dont alter when i set the width advice please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
Office Version
  1. 2007
Platform
  1. Windows
Here is the code for a Listbox.
I wish to be able to move the row number over so i can then see all the text to its left.
I have altered the row witdh 100 values but i see no movement in the columns for which i supply a screenshot.

Do you see an error which is not allowing me to do this ?

Thanks


VBA Code:
Private Sub FindInfo_Click()
  Dim r As Range, f As Range, Cell As String, added As Boolean
  Dim sh As Worksheet
 
  Set sh = Sheets("POSTAGE")
  sh.Select
  With ListBoxFind
    .Clear
    .ColumnCount = 2
    .ColumnWidths = "100;100" ' HERE
    If TextBoxSearchColumnD.Value = "" Then Exit Sub
    Set r = Range("D9", Range("D" & Rows.count).End(xlUp))
    Set f = r.Find(TextBoxSearchColumnD.Value, LookIn:=xlValues, LookAt:=xlPart)
    If Not f Is Nothing Then
      Cell = f.Address
      Do
        added = False
        For i = 0 To .ListCount - 1
          Select Case StrComp(.List(i), f.Value, vbTextCompare)
            Case 0, 1
              .AddItem f.Value, i
              .List(i, 1) = f.Row
              added = True
              Exit For
          End Select
        Next
           If added = False Then
          .AddItem f.Value
          .List(.ListCount - 1, 1) = f.Row
        End If
        Set f = r.FindNext(f)
      Loop While Not f Is Nothing And f.Address <> Cell
      TextBoxSearchColumnD = UCase(TextBoxSearchColumnD)
      .TopIndex = 0
      Else
      MsgBox "NO ITEM WAS FOUND USING THAT INFORMATION", vbCritical, "POSTAGE SHEET ITEM SEARCH"
      TextBoxSearchColumnD.Value = ""

    End If
  End With
  Me.ListBoxReplace.List = Me.ListBoxFind.List
End Sub


EaseUS_2024_11_ 3_13_51_56.jpg
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Actually this does nothing at all

VBA Code:
  With ListBoxFind
    .Clear
    .ColumnCount = 3
    .ColumnWidths = "150;150;150"
  End With

If i right click listbox & make alterations to column width there etc it works.

I like to use code to do it as most of the time i will forget about going to the properties box as mentioned
 
Upvote 0
I've downloaded your workbook before.
With over 50 user forms are you sure you're working with the right one ?
Your first code has 2 columns, now you have 3.
 
Upvote 0
Im working as i go so maybe column 2 to 3 will happen.
Need to work with file at present otherwise old code.
 
Upvote 0

Forum statistics

Threads
1,223,877
Messages
6,175,139
Members
452,615
Latest member
bogeys2birdies

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