excel vba - compare row's if value of corresponding column's not equal insert them -


i have 2 grouped of columns.one of them subset of another.i want write macro compare them , if not equal insert second 1 first one. algorithm ode:

if (code-1)<>(code-2) , (serial-1)<>(serial-2) , (amount-1)<>(amount-2)  (code-1)==(code-2) , (serial-1)==(serial-2) , (amount-1)==(amount-2) 

and want inserted row marked.

the table have below:

code-1  serial-1    amount-1    code-2  serial-2    amount-2 1         11          111          1      11          111 3         33          333          1      11           11                                    2      22           22                                    3      33           33                                    3      33          333 

the result looking below:

code-1  serial-1    amount-1    code-2  serial-2    amount-2    1     11           111          1      11          111    3     33           333          1      11          11    1     11           11           2      22          22    2     22           22           3      33          33    3     33           33           3      33         333 

update

this new code create 2 auxiliar columns run vlookup eliminate 1 dosen't match criteria when macro run select wich cells copy , delete these 2 columns after it's done.

but remenber wrote code according gave me, work if arrange, columns c , columns d f

if works please remember mark code answer appreciated =]

new code:

sub yoursub()  dim lstr1        long dim lstr2        long dim mark1        long  lstr2 = sheets(1).cells(rows.count, 4).end(xlup).row  lstr1 = sheets(1).cells(rows.count, 1).end(xlup).row + 1  mark1 = lstr1 - 1  range("a1").entirecolumn.insert range("a1").entirecolumn.insert  = 2 mark1  cells(i, 2) = cells(i, 3) & "-" & cells(i, 4) & "-" & cells(i, 5)  next  j = 2 lstr2  cells(j, 1).formular1c1 = "=vlookup(rc[5]&""-""&rc[6]&""-""&rc[7],c[1],1,false)"  next  j = 2 lstr2  if worksheetfunction.iferror(cells(j, 1), "error") = "error"  range(cells(j, 6), cells(j, 8)).copy cells(lstr1, 3).pastespecial xlpastevalues lstr1 = sheets(1).cells(rows.count, 3).end(xlup).row + 1  end if  next  range("a1").entirecolumn.delete range("a1").entirecolumn.delete  end sub 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -