0
votes

I created a macro that will copy over some information from one sheet in my workbook to another to match some criteria so I may import the info into a program. Only problem is after the macro runs, there are some blank rows and a couple duplicates. I have 12 columns of info but I would like to have the macro look at and compare entries in columns D,E,F,G and L with the row above them. So D2,E2,F2,G2 and L2 would be compared to D1,E1,F1,G1 and L1. IF all five of the entries in these cells match that of the previous row, then delete the entire row.

I've found some codes that match one cell or looks for duplicates in a certain column but nothing to look and match multiple columns and I'm so new to this that I'm having trouble even getting started.

Any and all input is welcome.

1
Sorting will move the blank rows together; the RemoveDuplicates method will let you specify multiple columns for the comparisonRon Rosenfeld

1 Answers

0
votes

You're going to have to put in the logic of your program yourself but use something like:

worksheets("Sheet1").range("A1").offset(i, 0).resize(1, colnum).delete Shift:=xlUp 

An easy way to find the commands you need is to record a macro and see what Excel uses to build that macro.