Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a file that contains two user-defined lists. When the user sets
values for these lists & clicks a macro button, I want the macro to go to the master data tab and filter the appropriate columns based on these values. (From there, I have additional code that does something else with the filtered data). I am unsure how to construct the code that filters multiple items from a list. Can someone lend some guidance on how to do this? (One other thing in case it matters---the user list may contain anywhere from 1-100 items) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See VBA help "AdvancedFilter Method". You need to put your filter list on a
range in the workbook and set the CriteriaRange in the Advance help method. "jday" wrote: I have a file that contains two user-defined lists. When the user sets values for these lists & clicks a macro button, I want the macro to go to the master data tab and filter the appropriate columns based on these values. (From there, I have additional code that does something else with the filtered data). I am unsure how to construct the code that filters multiple items from a list. Can someone lend some guidance on how to do this? (One other thing in case it matters---the user list may contain anywhere from 1-100 items) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
jday,
Assuming your list is in cell A2, and the other sheet is named Master Data: Sub FilterOtherSheet() Dim myKey As Variant Dim myArea As Range Dim myCol As Integer myCol = 2 'Column B myKey = Range("A2").Text Set myArea = Worksheets("Master Data").Cells(1, myCol).CurrentRegion myArea.AutoFilter Field:=myCol - myArea.Column + 1, Criteria1:=myKey End Sub HTH, Bernie MS Excel MVP "jday" wrote in message ... I have a file that contains two user-defined lists. When the user sets values for these lists & clicks a macro button, I want the macro to go to the master data tab and filter the appropriate columns based on these values. (From there, I have additional code that does something else with the filtered data). I am unsure how to construct the code that filters multiple items from a list. Can someone lend some guidance on how to do this? (One other thing in case it matters---the user list may contain anywhere from 1-100 items) |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worked like a charm! Thank you so much Bernie.
"Bernie Deitrick" wrote: jday, Assuming your list is in cell A2, and the other sheet is named Master Data: Sub FilterOtherSheet() Dim myKey As Variant Dim myArea As Range Dim myCol As Integer myCol = 2 'Column B myKey = Range("A2").Text Set myArea = Worksheets("Master Data").Cells(1, myCol).CurrentRegion myArea.AutoFilter Field:=myCol - myArea.Column + 1, Criteria1:=myKey End Sub HTH, Bernie MS Excel MVP "jday" wrote in message ... I have a file that contains two user-defined lists. When the user sets values for these lists & clicks a macro button, I want the macro to go to the master data tab and filter the appropriate columns based on these values. (From there, I have additional code that does something else with the filtered data). I am unsure how to construct the code that filters multiple items from a list. Can someone lend some guidance on how to do this? (One other thing in case it matters---the user list may contain anywhere from 1-100 items) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Filter range based on results of multiple selections in a listbox | Excel Programming | |||
Display all pivottable filter selections | Excel Worksheet Functions | |||
Data validation list drop-down values based on prior selections | Excel Programming | |||
Filter Excel Pivot, based on user entry form | Excel Discussion (Misc queries) | |||
Pop Up box to filter based on User Criteria | Excel Programming |