LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Comparing data in columns and delete if not equal

Hi Rob,
This code would work for you, try it out. Thanks to Ron. Just change the
Column from A to whatever you want and if you need to compare it to a column
other than the next one, change the OFFSET value. Hope it helps.

Sub Delete_rows_based_on_ColA_ColB2()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlNumbers)
For i = rng.Count To 1 Step -1
If rng(i).Value < rng(i).Offset(0, 1).Value Then
rng(i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


_______
Best regards,

Sean


"Robert" wrote:

Hello,
Do I need to replace the STOP with anything else?

My data is set this way.

ColA ColB ColC ColD ColE ColF
5/1/05 1 8 25 0.552 3
5/2/05 2 3 47 0.67 3
5/3/05 3 7 8 0.22 3

So for example, I need to compare column F with Column B and everytime there
is a common number in both columns I need to keep the whole row of data.
Otherwise I have to delete the row if Columns B and F dont match.
Hope it is more clearer now.
Thanks for the help.
Rob

"David" wrote:

Hi,
The stop can be removed sorry about that. Can you tell me how your data is
set up, which columns you are trying to compare? ie
ColA ColB ColC ColD ... etc
5 9 a z .....Etc

Then tell what you are comparing ColA and ColB or ColD and ColZ. It is set
up to start on the first value to compare and then compare it to the nest
column to the right, ie ColA and ColB or ColD and ColE.

Thanks,

"Robert" wrote:

Hi,
Im new to Macros and I was wondering if there is a simple macro to compare
two columns and see if they have the same value. If the columns dont match, I
need to delete the whole row.

Any guidance would be really appreciated.

Thanks
Rob

 
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
Comparing data between two columns ABeezy Excel Discussion (Misc queries) 4 May 13th 10 02:18 PM
Comparing data in two columns Norm Excel Worksheet Functions 1 June 10th 08 03:10 PM
Comparing columns of data chief775 Excel Discussion (Misc queries) 5 April 14th 06 05:11 AM
Comparing Data in 2 columns suzb Excel Worksheet Functions 2 January 6th 05 02:39 AM
Comparing Data in two columns Marianne Excel Worksheet Functions 3 November 5th 04 10:26 PM


All times are GMT +1. The time now is 02:25 PM.

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

About Us

"It's about Microsoft Excel"