Hi all!
I have a multi issue here with a listbox.
I'd like to make a listbox that shows only the selected columns with filtered data of my Database sheet. That page has 13 columns ("A:M") with data but I need only the A, C, D, and K columns to be visible. The last row needs to be dynamic and the filter is the all-time month. The 9th column ("I") has dates that needs to be filtered.
I have a code from my other listbox that is a simple one with a dynamic last row and headers.
Can I add a selected column list to this somehow or it is better to write a new one? I've tried this code with array but didn't work.
Thanks for the help.
I have a multi issue here with a listbox.
I'd like to make a listbox that shows only the selected columns with filtered data of my Database sheet. That page has 13 columns ("A:M") with data but I need only the A, C, D, and K columns to be visible. The last row needs to be dynamic and the filter is the all-time month. The 9th column ("I") has dates that needs to be filtered.
I have a code from my other listbox that is a simple one with a dynamic last row and headers.
VBA Code:
Private Sub ListBox1()
Dim sh As Worksheet
Dim last_Row As Long
Set sh = ThisWorkbook.Sheets("Database")
last_Row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
With Me.ListBox1
.ColumnHeads = True
.ColumnCount = 13
.ColumnWidths = "30,60,50,60,70,60,45,85,60,55,60,150,70"
If last_Row = 1 Then
.RowSource = "Database!A2:M2"
Else
.RowSource = "Database!A2:M" & last_Row
End If
End With
End Sub
Can I add a selected column list to this somehow or it is better to write a new one? I've tried this code with array but didn't work.
Thanks for the help.