Excel VBA - Combine and duplicate rows/columns -



Excel VBA - Combine and duplicate rows/columns -

can help or guide me on how can create macro in excel create new rows columns while duplicating other surrounding values?

for example, need turn this:

a 1 2 3 4 b c 5 6 7 8 d

into this:

a 1 b 2 b 3 b 4 b c 5 d c 6 d c 7 d c 8 d

i've found way combine columns using below macro:

sub singlecolumn() dim cursh worksheet, newsh worksheet, rng range, col long set cursh = activesheet set newsh = sheets.add cursh.activate set rng = application.intersect(selection, cursh.usedrange) col = 1 selection.columns.count rng.range(cells(1, col), cells(rng.rows.count, col)).copy newsh.range("a65536").end(xlup).offset(1, 0) next col end sub

modify code that:

sub singlecolumn() dim cursh worksheet, newsh worksheet, rng range, col long, row long set cursh = activesheet set newsh = sheets.add cursh.activate set rng = application.intersect(selection, cursh.usedrange) row = 1 selection.rows.count col = 1 selection.columns.count rng.range(cells(row, col).address).copy newsh.range("a1").offset(col - 1, row - 1) next next end sub

for me have little bit complicated macro ...

excel excel-vba

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -