Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Compare cells and copy columns after match | Excel Worksheet Functions | |||
How to compare two columns of data to make sure they match | Excel Worksheet Functions | |||
Compare columns in two WBks and when match is found... | Excel Programming | |||
Compare columns, delete the rows that DO match. | Excel Programming | |||
Want to compare two columns and then fill with data from the match | Excel Worksheet Functions |