Autofilter method of range class failed
I have a worksheet that filtered on a cell that utilized the
validation tool and it worked fine with this code: Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range If Target.Address = "$B$2" Then Set r = Me.AutoFilter.Range r.AutoFilter field:=9, Criteria1:=Range("b2").Value End If End Sub Now I added a combo box called ParentName and linked the cell to the combo box. the issue I have is the code does not recognize a change in cell B2. So I changed the code again and I get the range class failed error. Private Sub ParentName_Change() Dim r As Range Set r = Me.AutoFilter.Range r.AutoFilter field:=9, Criteria1:=ParentName.Value End Sub Can someone see where I went wrong? |
Autofilter method of range class failed
I received an answer in a different post.
On Jul 22, 9:44*am, Scott wrote: I have a worksheet that filtered on a cell that utilized the validation tool and it worked fine with this code: Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range If Target.Address = "$B$2" Then *Set r = Me.AutoFilter.Range *r.AutoFilter field:=9, Criteria1:=Range("b2").Value End If End Sub Now I added a combo box called ParentName and linked the cell to the combo box. the issue I have is the code does not recognize a change in cell B2. So I changed the code again and I get the range class failed error. Private Sub ParentName_Change() Dim r As Range Set r = Me.AutoFilter.Range r.AutoFilter field:=9, Criteria1:=ParentName.Value End Sub Can someone see where I went wrong? |
Autofilter method of range class failed
Any chance of posting what the solution was?
-- Many thanks, Gary Varga "Scott" wrote: I received an answer in a different post. On Jul 22, 9:44 am, Scott wrote: I have a worksheet that filtered on a cell that utilized the validation tool and it worked fine with this code: Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range If Target.Address = "$B$2" Then Set r = Me.AutoFilter.Range r.AutoFilter field:=9, Criteria1:=Range("b2").Value End If End Sub Now I added a combo box called ParentName and linked the cell to the combo box. the issue I have is the code does not recognize a change in cell B2. So I changed the code again and I get the range class failed error. Private Sub ParentName_Change() Dim r As Range Set r = Me.AutoFilter.Range r.AutoFilter field:=9, Criteria1:=ParentName.Value End Sub Can someone see where I went wrong? |
All times are GMT +1. The time now is 02:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com