Compare two columns, delete rows that match?
Hello,
I would like to compare columns B and C, and, if they match for a given row, delete or hide that row. B and C will be numbers (A is text) and as I am new to development in general, I unfortunately have no code to post. Any help would be much appreciated. Since this tool will be used by many non-tech folks many times a day, would it be best as a macro? Standalone ..exe? Excel '07 addin? Thank you very much in advance for your help. |
Compare two columns, delete rows that match?
Hi,
Right click the worksher name tab, view code and paste this in. At the end of the code use whichever line you want, one hides the rows and the other deletes them. Sub stance() Dim myrange, copyrange As Range Lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row Set myrange = Range("B1:B" & Lastrow) For Each c In myrange If c.Value = c.Offset(, 1).Value Then If copyrange Is Nothing Then Set copyrange = c.EntireRow Else Set copyrange = Union(copyrange, c.EntireRow) End If End If Next If Not copyrange Is Nothing Then 'copyrange.EntireRow.Hidden = True copyrange.Delete End If End Sub Mike "jhonnyc377" wrote: Hello, I would like to compare columns B and C, and, if they match for a given row, delete or hide that row. B and C will be numbers (A is text) and as I am new to development in general, I unfortunately have no code to post. Any help would be much appreciated. Since this tool will be used by many non-tech folks many times a day, would it be best as a macro? Standalone .exe? Excel '07 addin? Thank you very much in advance for your help. |
All times are GMT +1. The time now is 12:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com