How to merge fields of Excel when certain criteria meet -
i need merge rows have matching data. criteria if column sales order having same value should merge values of purchase order related sale order
before
after
i have tried this
sub test() dim c long, stdesc string, sttype string, dt date dim withdrawn double, dpaidin double, dbal double c = 1 while range("a2").cells(c, 1) <> "" if range("a2").cells(c, 1) > 0 dt = range("a2").cells(c, 1) ' dt = range("a2").cells(c, 1) sttype = range("b2").cells(c, 1) stdesc = stdesc & " " & range("c2").cells(c, 1) c = c + 1 loop until range("a2").cells(c, 1) <> "" range("a" & rows.count).end(xlup).offset(1, 0) = dt range("a" & rows.count).end(xlup).offset(0, 1) = sttype range("a" & rows.count).end(xlup).offset(0, 2) = stdesc range("a" & rows.count).end(xlup).offset(0, 3) = range("a2").cells(c - 1, 4) range("a" & rows.count).end(xlup).offset(0, 4) = range("a2").cells(c - 1, 5) range("a" & rows.count).end(xlup).offset(0, 5) = range("a2").cells(c - 1, 6) end if stdesc = "" loop end sub
Comments
Post a Comment