LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove opposite/almost matching entries?


Okay, firstly, please forgive the below code as, not having an
responses to these posts I've had to persevere myself which has led to
I'm sure, a pretty ugly and *******ised attempt.
However, it very nearly works now but I just need help with th
following which I still can't get to work:

Can anybody help me add an additional IF statement that is added, i
the value of thisrow = testrow is true? For example,

IF thisrow=testrow AND [same row as thisrow, column1].value = 'buy' AN
[same row as testrow, column1].value = 'sell' Then....

Currently it will work for the first match but then result in an objec
not defined error?

Please help, it's driving me mad!!!

Regards,

Adrian




Dim LastRow As Integer
Dim TestRow As Variant
Dim ReturnCell As Range
Dim firstrow As Range
Dim TestRange As Range
Dim ThisRange As Range
' Go to start of data range, get last row number and set first
' return marker

ActiveSheet.Range("A2").Select
LastRow = ActiveCell.End(xlDown).Row
Set ReturnCell = ActiveCell.Offset(-1, 0)

' Begin overall loop
For Row = 2 To LastRow

' Exit loop if next row is blank
If ActiveCell.Offset(1, 0) = " " Then Exit Sub

' Concatenate current row and capture address of ActiveCell
Set TestRange = ActiveCell
TestRow = ActiveCell.Offset(0, 5).Text & ActiveCell.Offset(0
9).Text _
& ActiveCell.Offset(0, 11).Text

'Set firstrow = ActiveCell.EntireRow

' Move to next row to begin testing for duplicates
ActiveCell.Offset(1, 0).Select

' Loop through remaining rows and delete duplicates of current row
For testrows = ActiveCell.Row To LastRow

' Concatenate current row
thisrow = ActiveCell.Offset(0, 5).Text _
& ActiveCell.Offset(0, 9).Text & ActiveCell.Offset(0, 11).Text
Set ThisRange = ActiveCell
' Compare value of current row against TestRow
' and delete row if same
If thisrow = TestRow Then ' And TestRange.Offset(0, 3).Value
"sell" And
'ThisRange.Offset(0, 3) = "buy" Then
'thisrow.EntireRow.Select 'Delete shift:=xlUp
TestRange.EntireRow.Interior.Color = vbYellow
ThisRange.EntireRow.Interior.Color = vbBlue
'firstrow.EntireRow.Delete Shift:=xlUp
Set ReturnCell = ReturnCell.Offset(-1, 0)
ThisRange.EntireRow.Delete Shift:=xlUp
TestRange.EntireRow.Delete Shift:=xlUp
LastRow = LastRow - 2

' If not equal, move to next row
Else: ActiveCell.Offset(1, 0).Select
End If

Next

' Go back to ReturnCell, advance to next row, reset ReturnCell
ReturnCell.Select
ActiveCell.Offset(1, 0).Select
Set ReturnCell = ActiveCell

Next

End Su

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

 
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
counting matching multiple entries colensa Excel Discussion (Misc queries) 2 May 17th 09 09:11 PM
Matching List Entries steev_jd Excel Discussion (Misc queries) 3 April 6th 06 03:11 PM
Matching and Copying entries Box666 Excel Discussion (Misc queries) 1 January 9th 06 09:45 PM
Help matching entries in two sheets??? Curalice Excel Worksheet Functions 2 November 12th 05 07:53 PM
matching column entries billytf Excel Worksheet Functions 6 April 11th 05 06:41 AM


All times are GMT +1. The time now is 06:00 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"