Question: Is it possible to write a macro to check 8 columns over 2000 rows and delete the duplicates? Answer: Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, we've set up values in columns A through H. On Sheet1, we've created a button that when clicked will launch a macro. This macro will delete any duplicate values (based on the values in columns A through H). When the macro has completed, a message box will appear that indicates how many duplicate rows were deleted.
|
After the macro has run, you can see that two rows have been deleted.
|
You can press Alt-F11 to view the VBA code. Please note that the LRows variable in this macro is set to 2000 indicating that the macro will test the first 2000 rows in for duplicates. You may need to change this value to accommodate your volume of data. Macro Code:The macro code looks like this:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc