+ Reply to Thread
Results 1 to 2 of 2

Error 1004 when setting range value

  1. #1
    Ricky Patel
    Guest

    Error 1004 when setting range value

    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


  2. #2
    Dave Peterson
    Guest

    Re: Error 1004 when setting range value

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1