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: 1
Default Run time error 1004: "No list was found.."


I ran this code

Code:
--------------------
Sub Macro2()
Dim wbTemplate As Workbook, CopyRng As Range
Dim iLtr As Integer, Criteria As String, FilePath As String

'can save this as a string so you can easily reference it in the code
FilePath = "S:\Wkgrps\Cbbfs\Product Development - Deposit\Large Amount Report\By ARM\new\"

On Error Resume Next
'makes sure the workbook is open
'if this line of code causes an error (workbook is not open)
Set wbTemplate = Workbooks("Large Amount Report By individual ARM Templete.xls")
If Err < 0 Then
'open the workbook and set to variable
Set wbTemplate = Workbooks.Open("Insert Path To File Here\Large Amount Report By individual ARM Templete.xls")
End If
On Error GoTo 0


With ThisWorkbook.Sheets("Sheet1")
'65~80 refers to letters A~P
For iLtr = 65 To 80
'create the string to filter for. For example, if iLtr=73 then the filter criteria will be "FBI"
Criteria = "FB" & Chr(iLtr)

'filter for the string
.Cells.AutoFilter Field:=1, Criteria1:=Criteria

'makes sure there are visible cells in the range A10:F50 after filtering
'if there are no visible cells within the range, error occurs and CopyRng is not set
On Error Resume Next
Set CopyRng = .Range("A10:F50").SpecialCells(xlCellTypeVisible)

'if error was NOT detected on above line of code
'and CopyRng variable was assigned a range
If Not CopyRng = Nothing Then
On Error GoTo 0
'copy the range to the template workbook
CopyRng.Copy Destination:=wbTemplate.Sheets("Sheet1").Range("A1 0")

'save the template workbook using criteria as part of filename
wbTemplate.SaveAs Filename:= _
FilePath & "Large Amount Report " & Criteria & ".xls", FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End If

'reset the copyrng to be blank
Set CopyRng = Nothing
On Error GoTo 0
Next iLtr
End With

End Sub
--------------------


But there is a Run time error 1004: "No list was found. Select a single
cell within your list, and then click the command again."

It refers to this part , (second "paragraph" specifically)

Code:
--------------------
With ThisWorkbook.Sheets("Sheet1")
'65~80 refers to letters A~P
For iLtr = 65 To 80
'create the string to filter for. For example, if iLtr=73 then the filter criteria will be "FBI"
Criteria = "FB" & Chr(iLtr)

'filter for the string
.Cells.AutoFilter Field:=1, Criteria1:=Criteria
--------------------


Although I criteria is set, it basically says ( I believe) that a cell
is not selected.

Any ideas?


--
hachiroku
------------------------------------------------------------------------
hachiroku's Profile: http://www.excelforum.com/member.php...o&userid=34039
View this thread: http://www.excelforum.com/showthread...hreadid=544225

 
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
how do I turn on document "editing time" found on advanced proper. cancer711 Excel Discussion (Misc queries) 2 May 24th 08 02:52 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM
"Run Time Error 1004 Application Defined or Object Defined Error." BJC Excel Programming 4 October 26th 03 03:09 AM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


All times are GMT +1. The time now is 11:22 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"