Hi guys, I have just started to learn excel vba, so please do bear with me here. I have a large sheet of data, and will require a macro to delete any two rows with opposite but equal amount in the cells of the fourth column, but provided that both rows start with S in the cells of the second column. Taking the below table as an example,[TABLE="width: 500"]
<tbody>[TR]
[TD]No.
[/TD]
[TD]Code
[/TD]
[TD]Name
[/TD]
[TD]Amount
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]54321
[/TD]
[TD]John
[/TD]
[TD]-1000
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]S12345678C
[/TD]
[TD]John
[/TD]
[TD]1000
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]S12345678A
[/TD]
[TD]John
[/TD]
[TD]-500
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]S12345678B
[/TD]
[TD]John
[/TD]
[TD]500
[/TD]
[/TR]
</tbody>[/TABLE]
After running the code I will need the remaining data to be:
[TABLE="width: 500"]
<tbody>[TR]
[TD]No.
[/TD]
[TD]Code
[/TD]
[TD]Name
[/TD]
[TD]Amount
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]54321
[/TD]
[TD]John
[/TD]
[TD]-1000
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]S12345678C
[/TD]
[TD]John
[/TD]
[TD]1000
[/TD]
[/TR]
</tbody>[/TABLE]
with both third and fourth rows deleted.
Will appreciate any help or assistance. Thanks a lot!
<tbody>[TR]
[TD]No.
[/TD]
[TD]Code
[/TD]
[TD]Name
[/TD]
[TD]Amount
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]54321
[/TD]
[TD]John
[/TD]
[TD]-1000
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]S12345678C
[/TD]
[TD]John
[/TD]
[TD]1000
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]S12345678A
[/TD]
[TD]John
[/TD]
[TD]-500
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]S12345678B
[/TD]
[TD]John
[/TD]
[TD]500
[/TD]
[/TR]
</tbody>[/TABLE]
After running the code I will need the remaining data to be:
[TABLE="width: 500"]
<tbody>[TR]
[TD]No.
[/TD]
[TD]Code
[/TD]
[TD]Name
[/TD]
[TD]Amount
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]54321
[/TD]
[TD]John
[/TD]
[TD]-1000
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]S12345678C
[/TD]
[TD]John
[/TD]
[TD]1000
[/TD]
[/TR]
</tbody>[/TABLE]
with both third and fourth rows deleted.
Will appreciate any help or assistance. Thanks a lot!