Filtering complications

hallingh

Well-known Member
Joined
Sep 11, 2010
Messages
769
Hi all. I have a workbook that charts data for survey results. The workbook currently works great. However, I'm now using four user form combo boxes and a macro button to allow uesrs to filter results based on Survey # (we give out the survey somewhat frequently, so we assign each group of surveys a number,) Time With company, etc. Again, there are four filters. I'm using this code to search through our sheet containing all the data, and populate a new sheet with the filtered data:

Code:
If Period1 = "All Periods" And Period2 = "All Periods" And DurObs = "All Durations of Observation" And DurPos = "All Durations in Position" Then
DataRangeNum = Sheets("Data_Import_Infopath").Range("AE" & Rows.Count).End(xlUp).Row
Sheets("Filtered_Data").Range("A4:A" & (DataRangeNum + 3)).Value = Sheets("Data_Import_Infopath").Range("AE1:AE" & DataRangeNum).Value
End If

As you can see, this is only for when the user wants to show all of tha data in each drop down. The problem with coding it this way is that since there are four drop downs for the user to choose from and each one has a choice to show all data, it would require 16 if and elseif statements for it to work. In other words, the user could select a specific item from one drop down, but leave the other three on all data, or he could select specific items from two drop downs but leave the other three on all data, etc.

Is there some way for me to tell vba to ignore a part of my code if the all data option is selected? Here is an example of what I want to do, but need more vba knowledge to accomplish:

Code:
Sub GetItDone()
Dim RowNum As Long
For RowNum = 2 to Sheets("Data_Import_Infopath").Range("AE" & Rows.Count).End(xlUp).Row
If Sheets("Data_Import_Infopath").Range("AF" & RowNum).Value = DurationPositionDropDown (code here to tell it to ignore if DurationPositionDropdown = All Durations in Position) And Sheets("Data_Import_Infopath").Range("AG" & RowNum).Value = DurationObservationDropDown (code here to tell it to ignore if DurationObservationDropdown = All Durations of Observation) etc. Then
Do This
Exit For
 
 
End Sub


I know, this probably isn't possible, but I'd rather not have to use a gazillion if statements. Also, if you know of a better way to do this, or think that this isn't possible, please let me know so I can start thinking of some other way to accomplish my goal. Any help is greatly appreciated!Thanks a lot for the looks.

Hank
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

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