LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error on advanced filter vba excel - 1004

Hi,

I get an error message of:

1004 - No list was found. Select a single cell within your list, and
then click the command again.

When I call the following sub:

Sub ExtractReps()
Dim ws1 As Worksheet
Dim wsNew As Worksheet
Dim rng As Range
Dim r As Integer
Dim c As Range
Set ws1 = Sheets("Sheet1")
Set rng = Range("A:BM")

'extract a list of Sales Reps
ws1.Columns("F:F").Copy _
Destination:=Range("BP1")
ws1.Columns("BP:BP").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("BN1"), Unique:=True
r = Cells(Rows.Count, "BN").End(xlUp).Row

'set up Criteria Area
Range("BP1").Value = Range("F1").Value

For Each c In Range("BN2:BN" & r)
'add the rep name to the criteria area
ws1.Range("BP2").Value = c.Value
'add new sheet and run advanced filter
Set wsNew = Sheets.Add
wsNew.Move After:=Worksheets(Worksheets.Count)
wsNew.Name = c.Value
rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("HRCN_For_Payroll").Range("B P1:BP2"), _
CopyToRange:=wsNew.Range("A1"), _
Unique:=False
Next
ws1.Select
ws1.Columns("BN:BP").Delete
End Sub


When I "debug" it highlights the following snippet of code:
ws1.Columns("BP:BP").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("BN1"), Unique:=True

Can anyone help - if i dont call the sub and just run as macro it all
works fine but i want to include it in vba and when i just try and
call the macro it doesnt work - any ideas would be much appreciated!!

Many thanks

Rachel
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error msg on Advanced Filter Helen Excel Discussion (Misc queries) 0 April 3rd 08 04:52 PM
Advanced Filter - error message Mifty New Users to Excel 2 May 25th 06 07:02 PM
Error using Advanced Filter Unique Records headly Excel Discussion (Misc queries) 5 May 9th 06 01:36 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Advaced filter error 1004 Tove Excel Worksheet Functions 0 February 28th 05 01:54 PM


All times are GMT +1. The time now is 06:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"