Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Subscript Error

Hi, I get 'Subscript Out Of Range' for the code below, even though
"Natwest1.xls"
does exist in that format, thanks


Sub coi()

Set fin = Application.Workbooks("C:\My Documents\Natwest1.xls")
lastrow = Cells(Rows.Count, 3).End(xlUp).Row
For i = 3 To lastrow
If Cells(i, 4) = "Hudson" Then
Cells(i, 4).EntireRow.Copy Destination:=fin.Cells(91, 1)
End If
Next


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Subscript Error

Try:
Set fin = Application.Workbooks("Natwest1.xls")
You don't need and can't have the path in that statement.

But it looks like you're gonna have some trouble with this:

Cells(i, 4).EntireRow.Copy Destination:=fin.Cells(91, 1)
maybe...
Cells(i, 4).EntireRow.Copy Destination:=fin.worksheets("sheet1").Cells(91, 1)



teresa wrote:

Hi, I get 'Subscript Out Of Range' for the code below, even though
"Natwest1.xls"
does exist in that format, thanks

Sub coi()

Set fin = Application.Workbooks("C:\My Documents\Natwest1.xls")
lastrow = Cells(Rows.Count, 3).End(xlUp).Row
For i = 3 To lastrow
If Cells(i, 4) = "Hudson" Then
Cells(i, 4).EntireRow.Copy Destination:=fin.Cells(91, 1)
End If
Next

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subscript Error

If it is open then it should be

set fin = workbooks("Natwest1.xls")

if you want to open it, then it should be

Set fin = Application.Workbooks.Open("C:\My Documents\Natwest1.xls")

Your half way between, so I can't tell what you want to do.

--
Regards,
Tom Ogilvy

"teresa" wrote in message
...
Hi, I get 'Subscript Out Of Range' for the code below, even though
"Natwest1.xls"
does exist in that format, thanks


Sub coi()

Set fin = Application.Workbooks("C:\My Documents\Natwest1.xls")
lastrow = Cells(Rows.Count, 3).End(xlUp).Row
For i = 3 To lastrow
If Cells(i, 4) = "Hudson" Then
Cells(i, 4).EntireRow.Copy Destination:=fin.Cells(91, 1)
End If
Next


End Sub



Reply
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:Subscript out of range Jay Excel Discussion (Misc queries) 1 April 10th 08 10:25 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM
Subscript Out Of Range Error? Michael Vaughan Excel Programming 3 November 9th 04 11:35 AM
Subscript Error Lacys Excel Programming 1 June 8th 04 02:22 PM
Subscript out of range error Tom Ogilvy Excel Programming 0 December 10th 03 12:48 AM


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