Gap btw rows in List Box

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,280
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
Is it possible to add function in given below code for showing rows two by two?
I wand gap btw the rows to make the list easy understanding when it show whole list.

Many thanks.


VBA Code:
Dim a, i As Long, ii As Long, b(), n As Long
ListBox1.Clear
With ComboBox1
If .Text = "" Then Exit Sub
If WorksheetFunction.CountIf(Worksheets("list").Range("a:a"), .Text) = 0 Then
Exit Sub
End If
a = Worksheets("list").Range("a1").Resize(Worksheets("list").Range("a" & Rows.Count).End(xlUp).Row, 35).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = .Text Then
n = n + 1: ReDim Preserve b(1 To 35, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
End If
Next
End With
With ListBox1
.ColumnCount = 35
.ColumnWidths = "0;0;150;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;42;0"
.Column = b
End With
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Just change the 1:
Rich (BB code):
n = n + 1: ReDim Preserve b(1 To 35, 1 To n)

For a 2:
Rich (BB code):
n = n + 2: ReDim Preserve b(1 To 35, 1 To n)


If you want the first item to start in the first row of the listbox, then add this line: n = -1 before "a = Worksheets..."

Rich (BB code):
    n = -1
    a = Worksheets("list").Range("a1").Resize(Worksheets("list").Range("a" & Rows.Count).End(xlUp).Row, 35).Value
 
Last edited:
Upvote 1
Solution

Forum statistics

Threads
1,215,095
Messages
6,123,072
Members
449,093
Latest member
ripvw

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