View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA Autofilter nightmare

This worked fine for me:

Private Sub CommandButton1_Click()
If frmECR.cboVendor.Text = "PG&E" Then
Sheets("PG&E").Range("ListPGE").AutoFilter _
Field:=1, _
Criteria1:=frmECR.cboAccountNumber.Text
End If
End Sub


Private Sub UserForm_Initialize()
cboVendor.AddItem "ABC"
cboVendor.AddItem "EF&G"
cboVendor.AddItem "PG&E"
cboVendor.AddItem "MN&O"
cboAccountNumber.AddItem 1
cboAccountNumber.AddItem 2
cboAccountNumber.AddItem 3
End Sub


The range ListPGE was located on sheet PG&E

--
Regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
Try

If frmECR.cboVendor.Text = "PG&E" Then
Sheets("PG&E").Range("ListPGE").AutoFilter _
Field:=1, _
Criteria1:=frmECR.cboAccountNumber.Text


--
Regards,
Tom Ogilvy

Jmbostock wrote in message
...
I've the following problem. When the the below code runs i get a
"Autofilter method of range class failed". It says the problem is with
the last line of code. The strange thing is that it even filters the
selected range, but it still has a problem with it.


If frmECR.cboVendor.Text = "PG&E" Then
Sheets("PG&E").Range("ListPGE").AutoFilter _
Field:=1, _
Criteria1:=frmECR.cboAccountNumber

This thing is driving me nuts. Any help you guys can give would be
appreciated.

Thanks

James


---
Message posted from http://www.ExcelForum.com/