Thread: Loops etc.
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Loops etc.

Jonathan

sorry, obviously over-engineered !

Try this:

Dim BottomRow As Long
Dim i As Long

BottomRow = Range("B65536").End(xlUp).Row

For i = BottomRow To 2 Step -1
If Range("B" & i).Value = _
Range("B" & i - 1).Value Then
Range("B" & i).ClearContents
End If
Next 'i

Regards

Trevor


"Jonathan Vickers" wrote in message
...
Thanks for all the help guys. I actually just want to delete the value in
the cell, rather than the whole row, but I think I should be able to work
out how to do that!

Thanks again,

Jon

"Jonathan Vickers" wrote in message
...
Hi,

I'm trying to get a macro to compare dates in successive rows and then
delete the date in the lower row (i.e. with higher row number) if it is

the
same as the date above, but I can't seem to get it to work. My plan was:

For i To BottomRow
If value in (B,i) = value in (B,i-1)
Then delete value in (B,i)

However I can't seem to get this to work.

Any help would be much appreciated,

Jon