HI VBA Experts…
I have the following:-
Worksheet called “COUNTRIES” and in cell M1 = “CODE_Group”, M2 = 99
Define Name = CODE_Group and the formula used is ‘=COUNTRIES!$M$1’
Define Name = GroupData and the formula used is ‘=OFFSET(CODE_Group,1,0,COUNTA(COUNTRIES!$M:$M)-1,1)’
My data worksheet is called “Data_PasteArea” with various data in Columns A:O and column O has formula based calculations resulting in 9, 99 OR blanks. I want to apply AutoFilter and select all rows that match with 99 (indicated above - M2 = 99) using VBA code.
My VBA code is giving - Run-Time error ‘-2147417848 (80010108)’:
Method ‘AutoFilter’ of object ‘Range’failed
VBA code is as follows -
Sub GROUP_Section()
Dim GroupData As Variant
Dim ws9 As Worksheet, ws99 As Worksheet
Dim rngCritList As Range, rngExtract As Range
Set ws9 = Worksheets("Data_PasteArea") 'Original Data
Set ws99 = Worksheets("COUNTRIES") 'List of exclusive codes = 99 only
Sheets("Data_PasteArea").Visible = True
Set rngExtract = ws9.Range("$O$1").CurrentRegion
Set rngCritList = ws99.Range("GroupData")
GroupData = rngCritList.Value
rngExtract.AutoFilter Field:=15, _
Criteria1:=Application.Transpose(GroupData), _
Operator:=xlFilterValues
Sheets("Data_PasteArea").Select
End Sub
Please could you help to correct where I am going wrong.
Thx
Dhiresh
Bookmarks