Load filtered data to listbox instead of worksheet

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello, I want to find out if this code below here can be made to load the data into a listbox instead of pasting it to the sheet. My knowledge is limited with the how. Thanks in advance.


Code:
Sub FilterDates()
  Dim rCrit As Range  
  Sheets("HOME").UsedRange.ClearContents
  With Sheets(“DATA”).UsedRange
    Set rCrit = .Offset(, .Columns.Count).Resize(2, 1)
    rCrit.Cells(2).Formula = "=SEARCH(TEXT(C2,""dd""),F2)"
    '.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=rCrit, Unique:=False
    .AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rCrit, copytorange:=Sheets("HOME").Range("B1"), Unique:=False
  End With
  rCrit.Cells(2, 1).ClearContents
End Sub
 
I will find a way to use some tricks in switching between years.
So now how do we get the filtered data into the listbox as before?

You could allow user to select month(s) on the userform

How do you want to filter?
- single month only
- range of months (example FROM Jan 2019 TO March 2019)
- whole of 2019
etc
 
Upvote 0

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.
Since the filter could handle for a single year, what I did was place a combobox and load it with "This Year" and "Last Year".

And adjacent it is other combobox with the months January to December. So when I select "This year" and then say January, then I set cell D1 value to 01-01-2019 before run the filter.

It's running cool and I am okay with that.

:)
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,739
Members
449,050
Latest member
excelknuckles

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