Problem with populate listbox using Application.Index

purinqui

New Member
Joined
Nov 30, 2019
Messages
29
Office Version
  1. 2019
Platform
  1. Windows
Hi everybody.
I have a problem with a population of a listbox using the method Application.index.

I need load a listbox with a series of data in a sheet.

I only need just some data (some rows) of the sheet. This data is filtered by a intelligent search that indicate which row should be load in the listbox.

My problem is:

I dont know how can i do, to manage the variable rows to be implemented with the Method Application.index.

What i could achieve so far is:

i can populate the listbox, but integrating the whole sheet:

VBA Code:
Private Sub datesearch_Change()

Worksheets("register").Activate
sizerow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Worksheets("register").AutoFilterMode = False
historial.ColumnHeads = False


Dim x, Arr As Variant


   Arr = Application.Index(Cells, Evaluate("ROW(1:" & Cells(Rows.Count, "A").End(xlUp).Row & ")"), Application.Transpose([row(1:15)])) 'Generating Array
 
  'Format of column date of the Array
  For x = 1 To UBound(Arr)
    Arr(x, 1) = Format(Arr(x, 1), "d/m/yyyy")
  Next
  
historial.List = Arr ' Populate Listbox


'Intelligent Search
i = 1
For rowin = 2 To sizerow

    dateinput = Worksheets("register").Cells(rowin, 1).Value

            If dateinput Like "*" & Me.datesearch.Value & "*" Or rowin = 1 Then


'''''''''''''''''Do something in order to only load the rows that match the search on the Listbox "historial"

            End If

Next


End Sub


Private Sub UserForm_Initialize()

'Definition of Listbox "historial"
With Me.historial

    .ColumnCount = 15
    .ColumnHeads = True
    
End With


End Sub

when i run the code, i get this:


a.PNG


But in this case the listbox is populated with all the data of the sheet, and i need only load some specifically rows, that i don't know which will be.

In my ignorancy, i need something like this¨:

Arr = Application.Index(Cells, Array(..................), Application.Transpose([row(1:15)]))
where on the dotted line, would go the rows that are determined by the intelligent search.

I would appreciate any help .

the file I'm working on:

 

Attachments

  • a.PNG
    a.PNG
    8.7 KB · Views: 26

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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