vba - How can I delete duplicate cells in excel based on the cell next to them? -


i'm trying delete duplicate rows based on value have in cell next them im new vba , im having problems writing code. excel this:

1 9789646122277 1392

2 9789646122277 1393

3 9789641570455 1389

4 9789641570455 1394

5 9786005383270 1391

6 9789645545268 1388

7 9789646761995 1395

8 9789646761995 1393

9 9789646761995 1391

the vba has find duplicates (for example 9789646122277), when found, should compare number on cell next them (1393 , 1392) , delete duplicate has less value on side. result :

1 9789646122277 1393

2 9789641570455 1394

3 9786005383270 1391

4 9789645545268 1388

5 9789646761995 1395

sub siftdata() dim i, j, toti integer  toti = range(cells(1, 1), cells(1, 1).offset(cells(1, 1).end(xldown), 0)).count - 1  = toti 1 step -1     if cells(i, 1) = "" goto nexti         j = - 1 1 step -1             if cells(i, 1) = cells(j, 1)                 if cells(i, 2) > cells(j, 2)                     cells(j, 2).entirerow.delete xlshiftup                     else: cells(i, 2).entirerow.delete xlshiftup                 end if             end if         next j nexti: next  end sub 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -