Loop through Column A in Excel VBA, get a random word from Column B and output the row in Column C -


i'm new vba macros , excel, , have small problem need solve.

say have column a has 20 rows of single word/letter, , column b has 5 rows of single word/letter.

how loop through column a, starting a1 , randomly select row in column b add form new string output in column c?

meaning want output in column c:

a1 (for each a) + b2 (random) a2 (for each a) + b4 (random) a3 (for each a) + b1 (random) a4 (for each a) + b3 (random) a5 (for each a) + b4 (random) a6 (for each a) + b2 (random) ... 

and on , forth.

anyone has idea how achieve this?

try:

sub hth()     dim rcell range     dim irandom integer      each rcell in range("a1:a20")         irandom = application.worksheetfunction.randbetween(1, 5)         rcell.offset(, 2).value = cstr(rcell.value & cells(irandom, "b").value)     next rcell  end sub 

as have tagged excel 2007 may need use instead:

irandom = round((5 - 1) * rnd + 1, 0) 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -