PC Review


Reply
Thread Tools Rate Thread

Error 1004 when setting range value

 
 
Ricky Patel
Guest
Posts: n/a
 
      3rd Nov 2005
I keep getting that Error 1004: Application-defined or object-defined
error, when it gets to line:
--->Range("res_REVIEWBY").Value = "love"

WHYYYY?
-----------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)


'On Error Resume Next
On Error GoTo ErrHandler
Dim myDoc As Worksheet
Set myDoc = ActiveSheet

If (Target.Cells.Row >= 5 And Target.Cells.Row <= 6) And
Target.Cells.Column = 3 Then
Range("res_REVIEWBY").Value = "love"
Range("res_SIGNBY").Value = "love"
Range("res_APPROVEBY").Value = "nut"
End If

ErrHandler:
MsgBox (Err & Err.Description)

End Sub

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Nov 2005
Since this code is in a worksheet module, excel assumes the unqualified ranges
(range("res_revewby")) belong to the worksheet that owns the code.

If you fully qualify the ranges, then maybe it'll work ok:

worksheets("othersheetname").Range("res_REVIEWBY").Value = "love"

Another problem would be if that range name didn't exist. Have you verified
that?

Ricky Patel wrote:
>
> I keep getting that Error 1004: Application-defined or object-defined
> error, when it gets to line:
> --->Range("res_REVIEWBY").Value = "love"
>
> WHYYYY?
> -----------------------------------------------------------------------------------------------
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> 'On Error Resume Next
> On Error GoTo ErrHandler
> Dim myDoc As Worksheet
> Set myDoc = ActiveSheet
>
> If (Target.Cells.Row >= 5 And Target.Cells.Row <= 6) And
> Target.Cells.Column = 3 Then
> Range("res_REVIEWBY").Value = "love"
> Range("res_SIGNBY").Value = "love"
> Range("res_APPROVEBY").Value = "nut"
> End If
>
> ErrHandler:
> MsgBox (Err & Err.Description)
>
> End Sub


--

Dave Peterson
 
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
Error 1004 opening workbook 1004 WembleyBear Microsoft Excel Programming 2 30th Nov 2009 02:33 PM
Error '1004' - the specified value is out of range. =?Utf-8?B?Q2hyaXM=?= Microsoft Excel Programming 13 20th Sep 2006 11:04 AM
Re: setting range().hidden=True causes range error 1004 Tom Ogilvy Microsoft Excel Programming 0 1st Sep 2005 09:11 PM
Re: setting range().hidden=True causes range error 1004 Tom Ogilvy Microsoft Excel Programming 0 1st Sep 2005 09:06 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Microsoft Excel Programming 3 7th Apr 2005 02:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:27 AM.