Insert repeating data into a column

justabc

Board Regular
Joined
Dec 6, 2002
Messages
86
If there is a column of 500 rows and each cell in the column has a single word, which does not repeat in the column; now my goal is to insert in every other cell a repeating digit-e.g. 4

so as an illustration:

start with a column 500 rows

word1
word2
word3
word4
word5
.
.
.
.
word 499
word500


and the goal after the insertion is to get to:

word1
4
word2
4
word3
4
word4
4
word5
...

word499
4
word500

How can this be done (besides manually)?

Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi

Try this. You don't say what sort of data you have to the right so whether you want to insert an entire row, or just move the current data down will have to be adjusted.

Tony

Sub eee()
Range("a2").Select
While Not IsEmpty(ActiveCell)
If Left(ActiveCell, 4) = "word" Then
ActiveCell.Insert shift:=xlDown
ActiveCell = 4
ActiveCell.Offset(2, 0).Select
End If
Wend
End Sub
 
Upvote 0
Hi justabc:

Let us have a look at the following ...
y040308h1.xls
ABCD
1sourceentryToAddAfterEveryWordupdated
2word14word1
3word24
4word3word2
5word44
6word5word3
74
8word4
94
10word5
114
Sheet8


Formula in cell C2 is ... =IF(MOD(ROWS($1:1),2)=0,$B$2,INDEX($A$2:$A$6,INT((ROWS($1:1)-1)/2)+1))

and this is then copied down as far as required. You may need to enhance the formula for more features -- but this should get you started.
 
Upvote 0
Assuming data is in column A

Code:
Sub test()

    Range("A1").Select
    Do
    ActiveCell.Offset(1, 0).Select
    ActiveCell.EntireRow.Insert
    ActiveCell.Value = 4
    ActiveCell.Offset(1, 0).Select
    x = x + 1
    Loop While x < 500

End Sub
 
Upvote 0
Assuming data is in column A

Code:
Sub test()

    Range("A1").Select
    Do
    ActiveCell.Offset(1, 0).Select
    ActiveCell.EntireRow.Insert
    ActiveCell.Value = 4
    ActiveCell.Offset(1, 0).Select
    x = x + 1
    Loop While x < 500

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top