Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Set data filter based on user selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Set data filter based on user selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Set data filter based on user selections

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Set data filter based on user selections

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter range based on results of multiple selections in a listbox Mctabish[_4_] Excel Programming 0 January 9th 09 07:57 AM
Display all pivottable filter selections AudKen Excel Worksheet Functions 0 October 28th 08 06:28 PM
Data validation list drop-down values based on prior selections David Excel Programming 2 September 26th 08 03:58 PM
Filter Excel Pivot, based on user entry form Jayco Excel Discussion (Misc queries) 1 August 16th 06 06:07 PM
Pop Up box to filter based on User Criteria Darin Kramer Excel Programming 0 February 22nd 06 12:43 PM


All times are GMT +1. The time now is 06:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"