+ Reply to Thread
Results 1 to 4 of 4

PasteSpecial Range class problem and inserting copied data

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Question PasteSpecial Range class problem and inserting copied data

    I am trying copy multiple rows of data and insert it between every existing row of data in my sheet.

    You can see this in the attached sheet. Insert Row.xlsm

    Row 3 and Row 4 should be copied and inserted between rows 5 and 6, 6 and 7, 7 and 8, etc.

    This must copy the cell formulas not the values. It must also copy the whole row not just the first column.

    I have tried the following code but it does not insert the actual formula it just inserts the values.

    Please Login or Register  to view this content.

    I have tried to modify the above as follows but it gives me the error "Unable to set the PasteSpecial Property of the Range class".

    Please Login or Register  to view this content.

    How can this be fixed to insert the copied rows with formulas not the values?

    I have spent countless hours trying to fix the code but it does not seem to be helping.

    If you can fix my code above or provide a totally different solution i would be very thankful!


    Thanks
    Last edited by [email protected]; 08-27-2012 at 02:09 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: PastSpecial Range class problem and inserting copied data

    Hello there,

    Try updating the following code:

    Please Login or Register  to view this content.
    To this, I've highlighted the change in red.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-03-2012
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: PastSpecial Range class problem and inserting copied data

    That does not appear to work for me.

    It seems to still be copying the values instead of the formulas.

  4. #4
    Registered User
    Join Date
    08-03-2012
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: PasteSpecial Range class problem and inserting copied data

    Ok so I got your suggestion to partially work. I changed the macro as below.

    Note i changed line 3 and line 10.

    Problem is the formula does not keeps its relative reference.
    Now it seems to copy the formula but it literally copies exactly what the formula is. Which means that cell references are not correct. If the cell refers to L2 the formula copied will also contain L2.

    I need the formula to change the reference so it matches with the row above it. Another words if the cell is inserted 10 rows below where it was copied it needs to reference L12 instead of L2.

    That's the whole $ sign thing but in this case i don't have dollar signs and its still keeping the exact reference point.

    Please help i think we are sooo close! Unless im missing something.


    Please Login or Register  to view this content.
    Last edited by [email protected]; 08-27-2012 at 06:11 PM.

+ 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