vba - How to split a row into columns for every three columns in excel? -
vba - How to split a row into columns for every three columns in excel? -
in excel, how split row set of columns. info in a1 : g1 should in first row, a1: c1 same first row, d1: g1 should end of first row.this should go on till info in first row limited g1.
the info have like
b c d e ... ae af ag 1 ab 2013/01/12 2013/02/23 233 2013/02/24 2013/03/11 500 2 cd 2013/01/12 2013/02/23 233 2013/02/24 2013/03/11 343 . . 200 xx xxxx/xx/xx xxxx/xx/xx xx xxxx/xx/xx xxxx/xx/xx xxx
i need split into:
b c d e 1 ab 2013/01/12 2013/02/23 233 . . 1 ab 2013/02/24 2013/03/11 500 2 cd 2013/01/12 2013/02/23 233 . . 2 cd 2013/02/24 2013/03/11 343 . .
how can done in excel, tried writing vb script, didn't go anywhere. can please help me this.
ok, seems have 2 cells static id , name series of 3 cells show pattern of date
,date
,number
. want bring right of first 2 cells repeating rows. should do.
sub split_and_stack() dim c long, r long, lc long, lr long dim ws1 worksheet, ws2 worksheet set ws1 = activesheet sheets.add after:=sheets(sheets.count) set ws2 = sheets(sheets.count) ws2.cells(1, 1).resize(1, 5) = array("id", "name", "start", "end", "number") ws1 lr = .cells(rows.count, 1).end(xlup).row lc = .cells(1, columns.count).end(xltoleft).column r = 1 lr c = 3 lc step 3 ws2.cells(rows.count, 1).end(xlup).offset(1, 0).resize(1, 2) = _ .cells(r, 1).resize(1, 2).value ws2.cells(rows.count, 1).end(xlup).offset(0, 2).resize(1, 3) = _ .cells(r, c).resize(1, 3).value next c next r end end sub
the next image may not show dates correctly should teh general idea. thought not provide ambiguous date transcribed either mm/dd/yy or dd/mm/yy when supplying sample data.
excel vba vbscript
Comments
Post a Comment