+ Reply to Thread
Results 1 to 9 of 9

Pasting data into every second row, and also pasting it as a duplicate

  1. #1
    Registered User
    Join Date
    07-02-2019
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    5

    Pasting data into every second row, and also pasting it as a duplicate

    Hi there,

    I need to copy the data in Column G of 'workings', and then paste it into 'template' at L39, but need each line to duplicate.
    So it will show:
    ICT.1516.001
    ICT.1516.001
    ICT.1516.003
    ICT.1516.003
    ICT.1516.004
    ICT.1516.004 etc - I'll need to do this for another 1 or 2 columns also (column T to J as per above)


    I also need to copy Column E from 'workings' and paste it into 'template' at D39, but have it paste into every second row:
    55

    55

    55

    54

    30
    I also need to do this with more columns

    Any help would be greatly appreciated!!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,532

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Hello rhibrown and Welcome to Excel Forum.
    For L39 and down try: =IFERROR(INDEX(Workings!G$7:G$11,ROUND(ROWS(A$1:A1)/2,0)),"")
    For D39 and down try: =IFERROR(IF(ISODD(ROW()),INDEX(Workings!E$7:E$11,ROWS(A$1:A2)/2),""),"")
    Note that the Template sheet is password protected and no password is provided therefore I am not attaching a copy as I can not inspect the workbook.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    07-02-2019
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    5

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Thanks for that!

    How would I put that into VBA?

  4. #4
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Try this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-02-2019
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    5

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Thanks!
    It comes up with run time error 91 - object variable or With block variable not set

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Pasting data into every second row, and also pasting it as a duplicate

    It worked ok for me - can you re-upload your spreadsheet so I can have a look at what's happening?

  7. #7
    Registered User
    Join Date
    07-02-2019
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    5

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Thanks for your help! Really appreciate it.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Pasting data into every second row, and also pasting it as a duplicate

    I'm not getting the same error, but I am getting other errors. Have you removed most of the data from the spreadsheet? I suspect that the cause of the problem for me is the code is expecting data to be where there is none? In any case, I have a couple general suggestions:

    1) Avoid declaring variables as Integers, and use Long instead. There are more rows in Excel than can fit in the Integer data type. Even if your spreadsheet doesn't have that many rows, there is no downside to using Long

    2) Avoid using Select and Activate - this will speed things up greatly

  9. #9
    Registered User
    Join Date
    07-02-2019
    Location
    Brisbane
    MS-Off Ver
    2016
    Posts
    5

    Re: Pasting data into every second row, and also pasting it as a duplicate

    Thanks for the advice.

    I'm not running the whole macro (as I'm not yet finished), I am just stepping through the lines. They're right at the bottom of Module 3.
    I'm getting the error on the line
    Do While Workings.Cells(rW, 7).Value <> vbNullString

+ 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. Check duplicate from userform values before pasting to worksheet VBA
    By rakotonirinas in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-08-2019, 04:37 AM
  2. [SOLVED] Two Totals Pasting to Wrong Column - The rest are pasting correctly
    By CHRISOK in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-20-2018, 05:00 PM
  3. [SOLVED] Copy a row, check table for duplicate, give option to overwrite duplicate before pasting
    By Frankie_The_Flyer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2017, 09:56 PM
  4. Button to Remove duplicate and pasting the deleted row in another sheet
    By lovinguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2013, 12:24 AM
  5. Replies: 9
    Last Post: 12-22-2009, 11:30 AM
  6. Replies: 1
    Last Post: 08-28-2005, 09:05 AM
  7. Replies: 3
    Last Post: 03-26-2005, 11:06 PM

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