+ Reply to Thread
Results 1 to 6 of 6

runtime error 1004 pastespecial method of range class failed

  1. #1
    Registered User
    Join Date
    08-19-2005
    Posts
    58

    runtime error 1004 pastespecial method of range class failed

    a vba-excel-based application i created for a client has been suffering from a bug, the runtime 1004 error.

    i can't figure out what the problem is, as i've tried it on two different computers and i can't reproduce it on either of them.

    Please Login or Register  to view this content.
    it fails during the pastespecial method.

    thanks.

  2. #2
    Dave Peterson
    Guest

    Re: runtime error 1004 pastespecial method of range class failed

    Is it this line
    shOppFit.Range(Range("Y4:Z4"), Range("Y4:Z4").End(xlDown)).Copy

    if Yes, try fully qualifying those ranges:

    with shOppFit
    .Range(.Range("Y4:Z4"), .Range("Y4:Z4").End(xlDown)).Copy
    end with

    The dots in front of the .ranges mean that that thing belongs to the object in
    the previous with statement.

    Without fully qualifying those ranges, those ranges will refer to the
    activesheet (or the worksheet that holds the code--if you're in a worksheet
    module).

    dreamz wrote:
    >
    > a vba-excel-based application i created for a client has been suffering
    > from a bug, the runtime 1004 error.
    >
    > i can't figure out what the problem is, as i've tried it on two
    > different computers and i can't reproduce it on either of them.
    >
    > Code:
    > --------------------
    >
    > shOppFit.Range(Range("Y4:Z4"), Range("Y4:Z4").End(xlDown)).Copy
    > With shTemp
    > .Activate
    > .Range("Q1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    > End With
    >
    > --------------------
    >
    > it fails during the pastespecial method.
    >
    > thanks.
    >
    > --
    > dreamz
    > ------------------------------------------------------------------------
    > dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
    > View this thread: http://www.excelforum.com/showthread...hreadid=507929


    --

    Dave Peterson

  3. #3
    Dave Peterson
    Guest

    Re: runtime error 1004 pastespecial method of range class failed

    Oops on the .pastespecial line....

    Are you using the same version of excel?

    xlpastevaluesandnumberformats was added in a newer version. Your client may not
    have that newer version.

    (maybe do two pastespecials values, then formats??)

    dreamz wrote:
    >
    > a vba-excel-based application i created for a client has been suffering
    > from a bug, the runtime 1004 error.
    >
    > i can't figure out what the problem is, as i've tried it on two
    > different computers and i can't reproduce it on either of them.
    >
    > Code:
    > --------------------
    >
    > shOppFit.Range(Range("Y4:Z4"), Range("Y4:Z4").End(xlDown)).Copy
    > With shTemp
    > .Activate
    > .Range("Q1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    > End With
    >
    > --------------------
    >
    > it fails during the pastespecial method.
    >
    > thanks.
    >
    > --
    > dreamz
    > ------------------------------------------------------------------------
    > dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
    > View this thread: http://www.excelforum.com/showthread...hreadid=507929


    --

    Dave Peterson

  4. #4
    Jim Thomlinson
    Guest

    RE: runtime error 1004 pastespecial method of range class failed

    Is the sheet you are trying to paste to protected???
    --
    HTH...

    Jim Thomlinson


    "Gary''s Student" wrote:

    > Does shTemp exist?
    > --
    > Gary''s Student
    >
    >
    > "dreamz" wrote:
    >
    > >
    > > a vba-excel-based application i created for a client has been suffering
    > > from a bug, the runtime 1004 error.
    > >
    > > i can't figure out what the problem is, as i've tried it on two
    > > different computers and i can't reproduce it on either of them.
    > >
    > >
    > > Code:
    > > --------------------
    > >
    > > shOppFit.Range(Range("Y4:Z4"), Range("Y4:Z4").End(xlDown)).Copy
    > > With shTemp
    > > .Activate
    > > .Range("Q1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    > > End With
    > >
    > > --------------------
    > >
    > > it fails during the pastespecial method.
    > >
    > > thanks.
    > >
    > >
    > > --
    > > dreamz
    > > ------------------------------------------------------------------------
    > > dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
    > > View this thread: http://www.excelforum.com/showthread...hreadid=507929
    > >
    > >


  5. #5
    Gary''s Student
    Guest

    RE: runtime error 1004 pastespecial method of range class failed

    Does shTemp exist?
    --
    Gary''s Student


    "dreamz" wrote:

    >
    > a vba-excel-based application i created for a client has been suffering
    > from a bug, the runtime 1004 error.
    >
    > i can't figure out what the problem is, as i've tried it on two
    > different computers and i can't reproduce it on either of them.
    >
    >
    > Code:
    > --------------------
    >
    > shOppFit.Range(Range("Y4:Z4"), Range("Y4:Z4").End(xlDown)).Copy
    > With shTemp
    > .Activate
    > .Range("Q1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
    > End With
    >
    > --------------------
    >
    > it fails during the pastespecial method.
    >
    > thanks.
    >
    >
    > --
    > dreamz
    > ------------------------------------------------------------------------
    > dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
    > View this thread: http://www.excelforum.com/showthread...hreadid=507929
    >
    >


  6. #6
    Registered User
    Join Date
    08-19-2005
    Posts
    58
    thanks for the replies, everyone.

    1. sheets are protected, but get unprotected before getting written.
    2. shtemp exists.

    this application works on my computer and on another one my office, but it doesn't work on the client's computer.

    dave, you may be onto something. i talked to the client yesterday, and found out he's using win2k. i coded this application in excel 2003, but he is probably using an older version.

+ 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