out of range error message

J

juergenkemeter

Hi,
When running the following function, there will be an error message
'subscript out of range'. I can't get to the point, why this happens.

If anyone has a suggestion, I would appreciate that.

VBA:

Sub Test()
Dim lStart As Long, lEnd As Long

With
Workbooks("OutOfRange.xls").Worksheets("Information").Columns(2)
On Error Resume Next
lStart = .Find("Database Searches").Row 'first header
lEnd = .Find("Holdings").Row 'second section header
On Error Goto 0
End With
End Sub

I also enclosed the file where this happens.

Cheers
Juergen


+-------------------------------------------------------------------+
|Filename: OutOfRange.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4241 |
+-------------------------------------------------------------------+
 
A

Anita

Hi Juergen,

I'm not a fan of downloading files with macros of unknown origin :) so
I can't really test this. But the only reason I can think that you
would get this error on this piece of code is that it can't find the
workbook or the worksheet by those exactly names so I would double
check for typos.

Good Luck!
 

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

Top