Filtering method from base on a cell value with VBA.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Good Day,
Below code is filtering the whole data base on below table sample cell K1 value from same worksheet.
So far everything is good with that code .

VBA Code:
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("A" & i)
If .Value = Range("k1").Value Then
.Offset(, 1).Resize(, 3).Copy
Range("m" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End If
End With
Next i
Application.ScreenUpdating = True
Range("K1").Select
ThisWorkbook.Save

Is it possible to add a more function for filterin on monthly basis.
Datas will be on worksheet1 as in below format and filtering function will be on worksheet2
On worksheet1 cell A1 I will simply put as list data validation for the months from jan to dec.
When I select to month from A1 as October, I want from customer ID's will load individually, not all will show up.
With sample below if October selected only 4 customers names will load with the code given above.

Many thanks.


DateCustomer IDName & Surname
10-Oct12359xxxxxx
10-Oct12359xxxxxx
10-Oct12359xxxxxx
10-Oct12359xxxxxx
10-Oct12359xxxxxx
10-Oct4395xxxxxx
10-Oct4395xxxxxx
10-Oct4395xxxxxx
10-Oct4395xxxxxx
11-Oct4395xxxxxx
11-Oct4395xxxxxx
11-Oct20491xxxxxx
11-Oct20491xxxxxx
11-Oct20491xxxxxx
11-Oct20491xxxxxx
11-Oct18426xxxxxx
12-Oct18426xxxxxx
12-Oct18426xxxxxx
12-Oct18426xxxxxx
12-Oct18426xxxxxx
12-Oct18426xxxxxx
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,224,813
Messages
6,181,107
Members
453,021
Latest member
Justyna P

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