Next, open the View tab > from Macros > select View Macros Then, if the compared value is equal then it will put the values in the adjacent column. Also used, FOR loops to check all values of Selection and CompareRange. I used an IF statement to compare whether the value of x and y is equal or not. Provided the cell range F5:F11 to Compare values. Here, I declared the Sub procedure Find_Matches_Comaring2Columns where CompareRange, x, and y are Variant type variables. Sub Find_Matches_Comaring2Columns()ĭim CompareRange As Variant, x As Variant, y As Variant Then, it will open Microsoft Visual Basic for Applications.Ī Module will open then type the following code in the opened Module. To begin the procedure, open the Developer tab > select Visual Basic Here, I want to find the matches of the Email_ID column. To compare two columns and to find matches you can use the VBA Macro as well. Using Macro to Find Matches Comparing Two Columns Related Content: Excel formula to compare two columns and return a value (5 examples) 2. Here both columns unique values are Highlighted. Hence, it will Highlight all the unique values of two-column.Īgain, you can run the Macro to compare Addresses. Now, from the Macro name select the Highlighting_Comparing_2Columns also select the workbook within Macros in. Next, open the View tab > from Macros > select View Macros Then, select the cell range to apply the VBA Then, if the compared value is unique by row, then it will Highlight it with Yellow color as I used ColorIndex = 6.įinally, Save the code and go back to the worksheet. I used an IF statement to compare the values of the selected cell range, also I used a FOR loop to check all the rows. Here, I declared the Sub procedure Highlighting_Comparing_2Columns where Twocolumns is Range type and i is Integer type variables. Next, it will open Microsoft Visual Basic for Applications.įrom there, open Insert > select Module.Ī Module will open then type the following code in the opened Module. You also can use the ALT + F11 keyboard to open the VBA editor. Now, open the Developer tab > select Visual Basic To do it I will take the same type of columns together. Using Macro to Highlight Unique Values Comparing Two Columnsīy using VBA Macro, you can Highlight the Unique values of two columns. 4 Ways to Use Excel Macro to Compare Two Columns 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |