Filter onto another sheet

Adam19931

New Member
Joined
Jun 22, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have a worksheet (sheet1) that contains multiple columns of data taken from an input form. I am looking for a formula or vba code that will allow the user to enter a week number into cell c3 on sheet2 and return all ID's from sheet1 (column A) that correspond to the inputted week number. These ID's are to be returned in cell C7 down on sheet2.

I am currently using a filter formula however this doesn't allow for sorts to be used on the data.

Thanks for your help in advance.


Sheet1
1672437898167.png

Sheet2
1672437842963.png
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi Adam,

maybe use the Advanced Filter and an event behind the sheet to trigger the event (my Excel is not able to read in the contents from pictures so I choose a different data set).

Sheet Data looks like this (only a small part of it)
MrE_1225747_1616D10_filter onto another_221231.xlsm
ABCDEF
1EEIDFull NameJob TitleDepartmentBusiness UnitGender
2E02387Emily DavisSr. MangerITResearch & DevelopmentFemale
3E04105Theodore DinhTechnical ArchitectITManufacturingMale
4E02572Luna SandersDirectorFinanceSpeciality ProductsFemale
5E02832Penelope JordanComputer Systems ManagerITManufacturingFemale
6E01639Austin VoSr. AnalystFinanceManufacturingMale
Data


Sheet Output looks like this without any option being taken in A2:
MrE_1225747_1616D10_filter onto another_221231.xlsm
ABCDE
1Department
2
3
4
5
6
7
Output
Cells with Data Validation
CellAllowCriteria
A2ListAccounting;Engineering;Finance;Human Resources;IT;Marketing;Sales


After making a choice:
MrE_1225747_1616D10_filter onto another_221231.xlsm
ABCDEF
1Department
2Finance
3
4
5EEIDFull NameJob TitleDepartmentBusiness UnitGender
6E01070Leonardo MartinManagerFinanceSpeciality ProductsMale
7E01639Austin VoSr. AnalystFinanceManufacturingMale
8E00187Miles MehtaDirectorFinanceResearch & DevelopmentMale
9E04088Ezra LiangVice PresidentFinanceResearch & DevelopmentMale
10E01845Leo FernandezManagerFinanceResearch & DevelopmentMale
Output
Cells with Data Validation
CellAllowCriteria
A2ListAccounting;Engineering;Finance;Human Resources;IT;Marketing;Sales


Data in Range starting with A5 can be sorted and will stay on sheet unless you make any other choice (data will be overwritten) or blank A2 (data starting with A5 will be cleared).

Code behind Sheet Output:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2")) Is Nothing Then
  If Not Target.Value = vbNullString Then
    Sheets("Data").Range("A1:N" & Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row).AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Range("A1:A2"), _
        CopyToRange:=Range("A5:N5"), _
        Unique:=False
  Else
    Range("A5").CurrentRegion.Clear
  End If
End If
End Sub

If your sorting will always be one column and directions this may be added to the code above.

Ciao,
Holger
 
Upvote 0
Solution

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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