+ Reply to Thread
Results 1 to 6 of 6

Copy And Paste Values Using VBA

  1. #1
    Registered User
    Join Date
    09-08-2014
    Location
    Houston, Texas
    MS-Off Ver
    10
    Posts
    17

    Copy And Paste Values Using VBA

    Hello,

    I am trying to write a Macro where it will use date and time (protected fields), and copy and paste values for only fields that have a formula. I am almost there, but I keep getting a debug run time error 1004.

    Please Login or Register  to view this content.
    Thank you,

    Daniel

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy And Paste Values Using VBA

    I am able to run this code without error. It would help if you would attach your actual file, so we can try it with your data.

    What line of code is highlighted when the error occurs?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-08-2014
    Location
    Houston, Texas
    MS-Off Ver
    10
    Posts
    17

    Re: Copy And Paste Values Using VBA

    I am now getting run time error '28':

    Out of Stack space. When I select debug it shows the below line highlighted.

    Please Login or Register  to view this content.
    I have also attached the file.

    Thank you,

    Daniel
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy And Paste Values Using VBA

    When you do the copy & paste, you are updating the worksheet and so the Worksheet_Change event is triggered again. The Sub is called again and again recursively until you run out of stack space. The way to prevent this is to turn off events while you update the sheet. See code below.

    Also, do you want to do that copy and paste every time there is any change or only when column A changes? If the latter then you need to move your End If down farther, as shown.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-08-2014
    Location
    Houston, Texas
    MS-Off Ver
    10
    Posts
    17

    Re: Copy And Paste Values Using VBA

    Oh, that was perfect. Thank you, 6StringJazzer.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Copy And Paste Values Using VBA

    You're welcome! Thanks for the rep. To mark your thread SOLVED, go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Formulas and Paste into the Last Set # of Rows Only & Paste Values
    By Mr. Ice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2014, 07:48 AM
  2. copy formula and paste for new data added and autofill.....and paste special values
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2014, 07:40 AM
  3. Copy and paste code pasting won't paste just values
    By thehotbreadguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2013, 11:12 PM
  4. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  5. VBA Copy-paste values with changing paste location
    By booost in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2012, 10:39 AM

Tags for this Thread

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