excel - Copy data from each column based in if condition -
i have data in sheet looks like
a b c d 1001 1002 1003 phone 1 1 1 tv 1 1 remote 1 ac 1 1 1
i want macro gives data in sheet like
phone 1001;1002;1003 tv 1001;1003 remote 1003 ac 1001;1002;1003
in 2 columns
this sample data, columns , rows vary every time large numbers 1000. need macro data first row, if corresponding cell has "1" in it.
this might ..
sub init() dim x, y integer dim s string dim xt worksheet set xt = sheets("sheet2")'----------> may change y = 2 6 '--------------------tv,remote,etc s = "" x = 2 4 '------------------1001,1002,1003 if cells(y, x) = 1 if len(s) > 0 s = s & "; " s = s & cells(1, x) end if next xt.cells(y, 1) = cells(y, 1) xt.cells(y, 2) = s next end sub
Comments
Post a Comment