macro criteria copy
Put it in the sheet, not in a code module, maybe?
SD
"Bob Phillips" wrote:
Well it worked for me, so what did you do with that code.
--
__________________________________
HTH
Bob
"puiuluipui" wrote in message
...
Hi, it's not working. It doesn't show me anything.
What am i doing wrong?
"Bob Phillips" wrote:
Public Sub ProcessData()
Dim sh As Worksheet
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long
Set sh = Worksheets("Sheet2")
sh.Range("G1:J1").Value = Array("data", "pers", "IN", "out")
NextRow = 2
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
If .Cells(i, "D").Value = .Cells(i + 1, "D").Value Then
If LCase(.Cells(i, "C").Value) = "in" And _
LCase(.Cells(i + 1, "C").Value) = "out" Then
sh.Cells(NextRow, "G").Value = .Cells(i, "A").Value
sh.Cells(NextRow, "H").Value = .Cells(i, "D").Value
sh.Cells(NextRow, "I").Value = .Cells(i, "B").Value
sh.Cells(NextRow, "J").Value = .Cells(i + 1,
"B").Value
i = i + 1
Else
sh.Cells(i, "G").Value = .Cells(i, "A").Value
sh.Cells(NextRow, "H").Value = .Cells(i, "D").Value
If LCase(.Cells(i, "C").Value) = "in" Then
sh.Cells(NextRow, "I").Value = .Cells(i,
"B").Value
Else
sh.Cells(NextRow, "J").Value = .Cells(i,
"B").Value
End If
End If
Else
sh.Cells(i, "G").Value = .Cells(i, "A").Value
sh.Cells(NextRow, "H").Value = .Cells(i, "D").Value
If LCase(.Cells(i, "C").Value) = "in" Then
sh.Cells(NextRow, "I").Value = .Cells(i, "B").Value
Else
sh.Cells(NextRow, "J").Value = .Cells(i, "B").Value
End If
End If
NextRow = NextRow + 1
Next i
End With
End Sub
--
__________________________________
HTH
Bob
"puiuluipui" wrote in message
...
Hi, i have a dabase like this...
A B C D
11/01 7:23:30 in ADRIAN
11/01 16:05:29 out ADRIAN
11/01 17:15:02 out ADRIAN
11/01 7:23:44 IN ALEC
11/01 16:04:34 out ALEC
11/03 12:17:22 IN ALEC
11/03 21:10:30 out ALEC
.....
...and i need a macro to extract datas in another sheet, like this:
G H I J
data pers IN out
11/01 ADRIAN 7:23:30 16:05:29
11/01 ADRIAN 17:15:02
11/01 ALEC 7:23:44 16:04:34
11/03 ALEC 12:17:22 21:10:30
I need everything to be sorted by name and date, ascending.
Can this be done?
Thanks in advance.
|