PDA

View Full Version : Count no. of item copied.



deedii
01-29-2012, 06:37 PM
Hi guys,

How do I count the number of item copied and prompt it in a message box. Im using the code below to copy the data.


Last_Rw = .Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To Last_Rw

If .Cells(i, "l").Value = "xxx" Then

WS_Pas.Cells(Rw_Ct, 1).Value = .Cells(i, "A").Value

Rw_Ct = Rw_Ct + 1
T_Str = T_Str & "A" & i & ","

End If
Next i


Thank you :)

defcon_3
01-29-2012, 06:52 PM
I think you mean like this?


Dim Count as Long
For i = 2 To Last_Rw
If .Cells(i, "l").Value = "xxx" Then
WS_Pas.Cells(Rw_Ct, 1).Value = .Cells(i, "A").Value
Rw_Ct = Rw_Ct + 1 T_Str = T_Str & "A" & i & ","
End If

Count = Count + 1
Next i

MsgBox Count & Space(2) & "files copied.", vbOKOnly

deedii
01-29-2012, 08:05 PM
Yes thats exactly what I mean, but I have a problem it also counts duplicated item. Is there any way to rewrite this one so that i can also count the number of duplicated item?


ActiveSheet.Range("$A$1:$X$5000").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7 _
, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24), Header:=xlYes