Listbox values from range question

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
Can anyone help me change the range that my Listbox is populated from?

Code:
Dim j As Long
Dim x As Long
ReDim a(1 To 7, 2 To 30) As Variant
x = 1
For j = 2 To 30
If Not Range("A" & j).Value = vbNullString And Range("G" & j).Value = vbNullString Then
x = x + 1
a(1, x) = Range("A" & j).Value
a(2, x) = Range("B" & j).Value
a(3, x) = Range("C" & j).Value
a(4, x) = Range("D" & j).Value
a(5, x) = Range("E" & j).Value
a(6, x) = Range("F" & j).Value
'A(7, X) = Range("G" & j).Value
a(7, x) = j
End If
Next j
If x > 1 Then
ReDim Preserve a(1 To 7, 2 To x)
Me.ListBox1.List = Application.Transpose(a)
'ListBox1.ColumnWidths = ";;;;;;"
End If

Currently it starts at row 2, but I want it now to start at 33 and end at 62.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Perhaps:

Code:
Dim j As Long
Dim x As Long
ReDim a(1 To 7, 2 To 30) As Variant
    x = 1
    [COLOR=#ff0000]For j = 33 To 62[/COLOR]
    If Not Range("A" & j).Value = vbNullString And Range("G" & j).Value = vbNullString Then
    x = x + 1
    a(1, x) = Range("A" & j).Value
    a(2, x) = Range("B" & j).Value
    a(3, x) = Range("C" & j).Value
    a(4, x) = Range("D" & j).Value
    a(5, x) = Range("E" & j).Value
    a(6, x) = Range("F" & j).Value
    'A(7, X) = Range("G" & j).Value
    a(7, x) = j
    End If
    Next j
    If x > 1 Then
    ReDim Preserve a(1 To 7, 2 To x)
    Me.ListBox1.List = Application.Transpose(a)
    'ListBox1.ColumnWidths = ";;;;;;"
End If
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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