Question: Is it possible to write a macro which would highlight any duplicate values where both columns A and B in two or more lines are the same? Answer: Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, we've set up values in both columns A and B. On this sheet, we've created a button that when clicked will launch a macro. This macro will highlight any duplicate values where both columns A and B in two or more lines are the same. In our example, we've clicked on the button. Now the background color of the duplicates will turn red as follows:
|
In this example, the same values have been entered in rows 2 and 6. You can press Alt-F11 to view the VBA code. Please note that the LRows variable in this macro is set to 200 indicating that the macro will test the first 200 rows in columns A and B 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