Marmaduke_88
New Member
- Joined
- Feb 18, 2012
- Messages
- 26
Excel 2003. I believe I've got everything working in the code up until:
It loops once and then "Run-time error '424': Object Required" for the code above.
In case I'm way off, I'm trying to get the code to do the following:
Column b is sorted ascending, so any matches should be next to each other. as I'm writing this, though - I realize that if there are triplicates or more in column B, this would need to be run more than once. Any suggestions?
Code:
If rnGx = rnGy Then
Code:
Sub test1()
Dim rnGx As Range
Dim rnGy As Range
Dim i As Long
Dim xNum As Integer
Dim yNum As Integer
i = 2
Set rnGx = Cells(i, 2)
Set rnGy = rnGx.Offset(1, 0)
xNum = rnGx.Offset(0, 2)
yNum = rnGy.Offset(0, 2)
With Sheet1
Do Until IsEmpty(ActiveCell)
If rnGx = rnGy Then
rnGx.Offset(0, 2) = (xNum + yNum)
rnGy.EntireRow.Delete
i = (i + 1)
Else
i = (i + 1)
End If
Loop
End With
End Sub
In case I'm way off, I'm trying to get the code to do the following:
- look for identical entries in column b
- where duplicates exist, sum the corresponding column d values into one of the existing columns
- delete the remaining duplicate
- do this until there are no matches
Column b is sorted ascending, so any matches should be next to each other. as I'm writing this, though - I realize that if there are triplicates or more in column B, this would need to be run more than once. Any suggestions?