Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare cells and copy columns after match Kcope8302 Excel Worksheet Functions 2 August 5th 09 05:37 PM
How to compare two columns of data to make sure they match Len Excel Worksheet Functions 0 June 24th 08 04:07 PM
Compare columns in two WBks and when match is found... DDawson Excel Programming 1 February 26th 08 07:37 PM
Compare columns, delete the rows that DO match. ryguy7272 Excel Programming 2 May 20th 07 04:34 PM
Want to compare two columns and then fill with data from the match Needy C Excel Worksheet Functions 1 January 11th 06 04:52 AM


All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"