Default300
Board Regular
- Joined
- Jul 13, 2009
- Messages
- 83
Can anyone explain why this code only works with the message box inserted?
And can you help me avoid having to have that line.
The code is the _click event code behind an OptionButton on a Userform.
The alternative OptionButton in the 2 button group removes all filters with: ActiveSheet.ShowAllData
Both OptionButtons are Bound to Separate ControlSources on the "LISTS" Worksheet.
I think I use standard RVBA naming convention, except for Worksheet Named Ranges, for which I use the improvised "nam" prefix, eg "namSomeText".
(Incidentally, if there is a standard convention for this I'd be happy to learn about it.)
The following is a selection of previous attempts at coding the AdvancedFilter.
Some permutations trialled are not shown as they were deleted...
Thanks in advance.
And can you help me avoid having to have that line.
The code is the _click event code behind an OptionButton on a Userform.
The alternative OptionButton in the 2 button group removes all filters with: ActiveSheet.ShowAllData
Both OptionButtons are Bound to Separate ControlSources on the "LISTS" Worksheet.
I think I use standard RVBA naming convention, except for Worksheet Named Ranges, for which I use the improvised "nam" prefix, eg "namSomeText".
(Incidentally, if there is a standard convention for this I'd be happy to learn about it.)
Code:
Private Sub optFiltersAllActivatedEnable_Click
Code:
'(AIM) Enable All Selected Filters
' (Show Only Records Which Match One Or More Criteria Selected)
'(i) Ensure Routine will Only Run If ActiveSheet is a "STATS" Sheet
If Left(ActiveSheet.Name, 5) <> "STATS" Then
MsgBox "Please Select a ""Statistics"" Worksheet First"
Exit Sub
End If
Application.ScreenUpdating = False
'[***] [BUG] AdvancedFilter WILL NOT WORK,
' UNLESS a MesssageBox Appears at this point!
' Without it, No Records are returned.
' Text of Message is irrelevant.
MsgBox "Random Text"
'(i) Apply AdvancedFilters
' Range to Filter is a Named Range: "namSheetDataEntrySortAreaInclHeader"
' Range to Filter is on a Worksheet called: "STATS (MAR 09) (Print) (5)"
' Filter Criteria Range is on Worksheet called: "LISTS" (in Same Workbook)
With ActiveSheet
.Range("namSheetDataEntrySortAreaInclHeader").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Worksheets("LISTS").Range("namListsCriteriaRange"), _
Unique:=False
End With
'(i) Scroll To First Row In Data Entry Sheet Interventions Area
ActiveWindow.ScrollRow = Range("namSheetDataEntryInterventionsAll").Row
vsbNavigateScrollVertical1.Value = ActiveWindow.ScrollRow
'(i) Move Cursor To "Safe" Blank Cell
Range("namSheetDataEntrySafeCell").Select
Application.ScreenUpdating = True
End Sub
The following is a selection of previous attempts at coding the AdvancedFilter.
Some permutations trialled are not shown as they were deleted...
Code:
' With Sheets("STATS (MAR 09) (Print) (5)")
' .Range("$A$6:$CY$891").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Worksheets("LISTS").Range("$AT$5:$AV$11"), _
Unique:=False
' Range("namSheetDataEntrySortAreaInclHeader").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Range("namListsCriteriaRange"), _
Unique:=False
Thanks in advance.