Excel Copy/Paste Question - Page 1
Forum section: electronics / general

author: bostonman
author_rank: Super Contributor
timestamp: April 06, 2020, 04:15:11 pm
content: I'm in need of copying something to every third line in Excel. So far adding spaces is easy because I have a macro that adds X spaces between rows (I can edit the macro to change the number).Currently column A has a part number in every third row (starting at A1, next is in A4, etc..) and column B has the same (but starting in B2, next is B5, etc..)I need to make A2 equal to B2, copy that formula () all the way down, and not delete what is in A4, A7, etc...Can someone give me an idea on how to do this?

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2020, 04:23:49 pm
content: Make an intermediary column with an if formula in every cell. If the line number is of form 1+3n, then you copy from next row of column B, else you copy from the same row of column A.

author: bostonman
author_rank: Super Contributor
timestamp: April 07, 2020, 02:11:50 am
content: What is the N in 1+3N?

author: CatalinaWOW
author_rank: Super Contributor
timestamp: April 07, 2020, 05:23:45 am
content: Quote from: bostonman on April 07, 2020, 02:11:50 amDepending on your Excel foo the line number, or a reference to yet another hidden column which has index numbers (set up as 1 in line one, and 1+ cell above for the rest).

author: RoGeorge
author_rank: Super Contributor
timestamp: April 07, 2020, 06:37:06 am
content: Multiple of 3 but 1 line shifted. Here is an example:Code:old part number10842000 new part numberold part number1084old part number10852001 new part numberold part number1085old part number10862002 new part number2003 new part numberold part number10872003 new part numberold part number1087old part number10882004 new part numberold part number1088old part number10892005 new part number2006 new part numberold part number10902006 new part numberold part number1090old part number10912007 new part numberold part number1091old part number10922008 new part number2009 new part numberold part number10932009 new part numberold part number1093old part number10942010 new part numberold part number1094To produce the 3rdcolumn, write the following formula in the first cell of the 3rdcolumn:Code:=IF(MOD(ROW(),3)=0,B2,A1)press enter, then double click on the lower right corner of the cell to autocomplete the formula to the next cells of the same column, or alternatively drag the formula down manually. Just an example, the formula can be written in many ways, adjust it to your needs. row() returns the row number of a cell, and mod(a, b) is the modulo function, it returns the remainder of a divided by b. My list separator is comma ',', if yours is something else, e.g. the semicolon character ';' , then in the above formula replace all comma characters with a semicolon character.If the results must be back in the column A, either make a new copy, or copy the result from the 3rd column and paste it "As Values" over the first column, your choice.

author: bostonman
author_rank: Super Contributor
timestamp: April 07, 2020, 01:52:38 pm
content: I need spaces between stuff.So I need:number 1alt number 1spacespacenumber 2alt number 2etc....

author: bostonman
author_rank: Super Contributor
timestamp: April 07, 2020, 03:35:01 pm
content: Never mind, I got my answer... it was actually easier than I was making it out to be.Thanks.

author: rrinker
author_rank: Super Contributor
timestamp: April 07, 2020, 03:53:36 pm
content: New versions of Excel are amazing with repetitive tasks - if you do a few, it makes very educated guess as to what you intend and suggests automatically implementing that same pattern over the rest of the range.