View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Copy text in colum each time it is a new text

Hi,

Am Thu, 10 Mar 2016 15:34:37 GMT schrieb :

A B C
20160311 3635127 X8YELLOW
20160311 3635127 X8YELLOW
20160311 3635127 X8YELLOW
20160310 6355014 G9BLACK
20160310 6355014 G9BLACK
20160310 6355014 G9BLACK

The sheet test should look like this:
20160311 3635127 X8YELLOW
20160310 6355014 G9BLACK


try:

Sub Test()
Dim LRow As Long, i As Long
Dim varData As Variant

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
varData = .Range("A1:C" & LRow + 1)
End With

For i = 2 To UBound(varData)
If varData(i, 3) < varData(i - 1, 3) Then
Sheets("test").Cells(Rows.Count, 1).End(xlUp)(2) _
.Resize(1, 3) = Application.Index(varData, i - 1)
End If
Next
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional