PC Review


Reply
Thread Tools Rate Thread

check.offset

 
 
=?Utf-8?B?ZGF2ZW5mZQ==?=
Guest
Posts: n/a
 
      13th Jul 2007
What is this function trying to do...I have added two sheets and not this
function does not complete and Run time error "1004". Application-Defined or
Object-error Defined occues.....help

Function find_range(worksheetcur As Worksheet, criteria As String, rowoffset
As Integer) As Range
Dim check As Range
Dim tmprange As Range

Set check = worksheetcur.Range("A1")
flag = 1
Do While flag = 1
check1 = InStr(check.Value, criteria)
If check1 > 0 Then
Set tmprange = check.Offset(1 + rowoffset, 1)
flag = 0
Else
Set check = check.Offset(0, 1)
flag = 1
End If
Loop
Set find_range = tmprange
End Function
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      13th Jul 2007
Your code is advancing past column 256 causing an error.
the code below will stop the error. It will not fix the error.

You really need to go to one of the old sheets and find the call to the
function. Use Edit and search for "find_range" (don't include double
quotes). then look at the second and third parameters. the second parameter
is the string checked and the third parameter is the row that is being looked
at. You need to do something similar on the new worksheets.

This function may not be on a worksheet but being called from another macro.
Also check inside the VBA editor for a "CALL find_range".





Function find_range(worksheetcur As Worksheet, criteria As String, rowoffset _
As Integer) As Range
Dim check As Range
Dim tmprange As Range

Set check = worksheetcur.Range("A1")
flag = 1
Do While flag = 1
check1 = InStr(check.Value, criteria)
If check1 > 0 Then
Set tmprange = check.Offset(1 + rowoffset, 1)
flag = 0
Else
If check.Column <> Columns.Count Then
Set check = check.Offset(0, 1)
Else
flag = 0
End If
End If
Loop
Set find_range = tmprange
End Function

"davenfe" wrote:

> What is this function trying to do...I have added two sheets and not this
> function does not complete and Run time error "1004". Application-Defined or
> Object-error Defined occues.....help
>
> Function find_range(worksheetcur As Worksheet, criteria As String, rowoffset
> As Integer) As Range
> Dim check As Range
> Dim tmprange As Range
>
> Set check = worksheetcur.Range("A1")
> flag = 1
> Do While flag = 1
> check1 = InStr(check.Value, criteria)
> If check1 > 0 Then
> Set tmprange = check.Offset(1 + rowoffset, 1)
> flag = 0
> Else
> Set check = check.Offset(0, 1)
> flag = 1
> End If
> Loop
> Set find_range = tmprange
> End Function

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Box linked cell offset Tracey Microsoft Excel Programming 1 8th Feb 2010 08:59 AM
Check for >0, then offset down 310, left 4, Check for = 0 ryguy7272 Microsoft Excel Programming 6 9th Dec 2009 04:01 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul =?Utf-8?B?UnlHdXk=?= Microsoft Excel Worksheet Functions 2 28th Sep 2007 10:54 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul =?Utf-8?B?UnlHdXk=?= Microsoft Excel Programming 4 28th Sep 2007 09:59 PM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny Microsoft Excel Programming 10 7th Dec 2006 11:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:38 AM.