Sunday, 15 July 2012

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


I've grouped two columns. One of them is the subset of another. I want to write a macro and if they were not compared to the first one, the algorithm was OD:

  if (code -1)  

And I want the inserted row to be marked.

I have a table below like this:

  Code-1 serial-1 sum-1 code -2 serial-2 sum-1 1 11 111 1 11 111 3 33 333 1 11 11 2 22 22 3 33 33 33 333  

I see the result is below:

  Code-1-serial-1 sum -1 Code -2 Serial -2 Amount -2 2 11 11 1 111 111 3 33 333 1 11 11 11 11 22 22 22 22 3 33 33 33 33 33 33 333  

UPDATE

This new code will create 2 helpful columns to run a vlookup to end them all Virtual Mac to copy which macro After selecting them to run, the criteria will not match and after this, remove these 2 columns.

But remember I wrote the code according to the code given by you, so it will only work when it is arranged, from column A to column and from column D to

< P> If this works, please remember to mark this code. Answer: A lot of praise =]

New code:

  Due to your () slow lstr1 long Longer lust2 = Sheet (1) long as long as dull mark1 as dull lstr2. (Rows number, 4). End (xlUp) .ro lstr1 = sheets (1). Game (rows number, 1). End (XLEP) .ro + 1 mark 1 = lstr1 - 1 range ("A1"). EntireColumn.Insert Range ("A1"). Mark 1 cell for I = 2 for EntireColumn.Insert (i, 2) = cell (i, 3) & amp; "-" & amp; Cells (i, 4) & amp; "-" & amp; Lstr2 cells (J, 1) from J = 2 for the next (i, 5) cells. Formul R1c1 = "= VLOOKUP (RC [5] and" "-" "and RC [6] and" "-" "& Amp; RC [7], c [1], 1, false ) "For next j = 2 to lstr2 if worksheet function. IFError (Cell (J, 1), "Error") = "Error" then range (cell, 6), cells (J, 8)) copy cell (lstr1, 3). Paste Special xlPasteValues ​​lstr1 = Sheets (1) .mail (rows.account, 3). End (XLEEP). Row + 1 end if the next range ("A1"). The entire column. DELETE RANGE ("A1"). The entire column. Remove end  

No comments:

Post a Comment