IF Duplicate row then cell
On 8 May, 10:00, wrote:
On 8 May, 09:49, "Roger Govier" wrote:
Hi
Assuming the data is sorted by Name, and that there are always matching
pairs of data then the following would work
Sub addLabels()
Dim lr As Long, i As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr Step 2
If Cells(i, 2) = Cells(i + 1, 2) Then
If Cells(i, 3) = Cells(i + 1, 3) Then
Cells(i, 5) = "CashW"
Cells(i + 1, 5) = "SecW"
End If
End If
Next
End Sub
--
Regards
Roger Govier
wrote in message
oups.com...
Col A Col B Col C Col D
050807 John Bell -100.00 CashW
050807 John Bell -100.00 SecW
060807 Andrew Davis 580.00 CashD
060807 Andrew Davis 580.00 SecB
Hi There
I would like a speadsheet than can identify two matching rows and then
in column E (the above data is for example) enter a value based on two
critera. The criteria being;
IF Row matches THEN in Column of the row enter "CashW" and then for
the next row that matches in column E cell enter "SecW".
In the example data Columns A, B and C are already completed, I need
a macro to populate Column D (Actually column E in my real data)
Someone please help,
Kind Regards,
Andrea- Hide quoted text -
- Show quoted text -
Hi Roger
This does not work.
I used names as an example but it maybe that I have the same
description in some of the cells. Even some of the amounts are the
same.
The only thing I can guarantee is that both rows will appear one after
the other.
If its a negative number then the first row should be "CashW" and the
second row "SecW" and if its a positive the first row should be
"CashD" and the second row should be "SecD".
I hope you can help as this has been driving me mad......I do this
manually every month....
such a nightmare.
thanks
Andrea- Hide quoted text -
- Show quoted text -
Hi Roger
This macro labels everything even the negative figues in column D with
a "CashD" label and a "SecD" Label.
It should be if the cell in column D is negative then label with
"CashW" and "SecW"
if its a positive number then label with "CashD" and "SecD"
Many thanks
Sorry if this is confusing.
Andrea
|