code failure

  • Thread starter Thread starter dreamz
  • Start date Start date
D

dreamz

i can't figure out what's wrong with this code:


Code
-------------------

Private Sub cbMSA_Change()
If cbMSA.Value = "Please select MSA" Then
Range("D42:Y42").AutoFilter Field:=2
Else
Range("D42:Y42").AutoFilter Field:=2, Criteria1:=cbMSA.Value
End If
End Sub

-------------------


i copied and pasted from another section and made the necessary change
to the names. i get: run-time error 1004: autofilter method of rang
class failed.

any ideas
 
interesting. i have two separate pieces of code that do something, an
now i'm just testing. whenever i run the first macro, the error pops u
in the second one, even though cbMSA was not touched. what's going on?


Code
-------------------

Private Sub cbForm_Change()
If cbForm.Value = "Please select formulary" Then
Range("D42:Y42").AutoFilter Field:=1
Range("D42:Y42").AutoFilter Field:=2
Else
Range("D42:Y42").AutoFilter Field:=1, Criteria1:="Last Update"
Range("D42:Y42").AutoFilter Field:=2, Criteria1:="Abilene, TX"
End If
End Sub

Private Sub cbMSA_Change()
'If cbMSA.Value = "Please select MSA" Then
' Range("D42:Y42").AutoFilter Field:=2
'Else
Range("D42:Y42").AutoFilter Field:=2, Criteria1:="Abilene, TX"
'End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top