Good day!
I would like to ask your help regarding the vba code that I need to enter in making my list automated.
What I want is that whenever I select from the dropdown menu, the table will be automatically be filtered without including the blank ones. I was able to attain this, but, an error appears. It needs me to have the table, initially filtered.
Here is my code.
So, where could I put this code to make it work?
Or, is my code correct?
Kindly, I need your help badly.
Thank you very much!
More power to you all!
I would like to ask your help regarding the vba code that I need to enter in making my list automated.
What I want is that whenever I select from the dropdown menu, the table will be automatically be filtered without including the blank ones. I was able to attain this, but, an error appears. It needs me to have the table, initially filtered.
Here is my code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="PASS"
If Target.Address(True, True) = "$B$7" Then
Select Case Target
Case ""
Range("B12:G12").Select
ActiveSheet.ShowAllData
Range("C13").Select
Range("C12:G262").Select
Selection.ClearContents
Application.ScreenUpdating = False
Range("B7").Select
Case "SHEET 1"
Range("B12:G12").Select
ActiveSheet.ShowAllData
Range("C13").Select
Range("J13:N262").Select
Selection.Copy
Range("C13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Application.ScreenUpdating = False
Range("C13:G262").Select
Application.AddCustomList ListArray:=Array("1", "2", "3", "4" _
, "5", "6", "7", "8", "T9", "10")
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range( _
"E13:E262"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"1,2,3,4,5,6,7,8,9,10" _
, DataOption:=xlSortNormal
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range( _
"G13:G262"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range( _
"D13:D262"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("C13:G262")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Application.ScreenUpdating = False
End With
ActiveSheet.Unprotect Password:="PASS"
Range("C13:G262").Select
Selection.Replace What:="ZZ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("B7").Select
Application.ScreenUpdating = False
Range("B7").Select
Application.ScreenUpdating = False
Case Else
'Do nothing
End Select
End If
ActiveSheet.Protect Password:="PASS", AllowFiltering:=True
End Sub
So, where could I put this code to make it work?
Code:
ActiveSheet.Range("$B$12:$G$262").AutoFilter Field:=2, Criteria1:="<>"
Or, is my code correct?
Kindly, I need your help badly.
Thank you very much!
More power to you all!