VBA cut/paste in another tab

Closed
Lyriste - Dec 22, 2014 at 09:38 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Dec 22, 2014 at 12:00 PM
Dear all,


I'm trying to copy in a different tab all rows that indicate in column [AN] a value less to or equal to 12. However, this column, as it refers to the duration left in mission of an employee, can sometimes also be filled by "Finished".



I am really a beginner in VBA so please forgive me if the answer is quite easy, it is still out of my grasp!



I tried the following code but it doesnt seem to work at all:



Sub Bouton1_Cliquer()

Set i = Sheets("Data base")
Set e = Sheets("Feuil4")
Dim d
Dim j
d = 3
j = 5

Do Until j = 9999

If i.Range("AM" & j) <= 12 Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
i.Select
Rows(j).Copy

e.Select
Rows(d).PasteSpecial

End If
j = j + 1
Loop

End Sub


I would appreciate any help!!
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Dec 22, 2014 at 12:00 PM
Hi Lyriste,

Consider this structure and let us know where you get stuck.
Sub Bouton1_Cliquer()
Dim lRow As Integer

lRow = Range("AM" & Rows.Count).End(xlUp).Row

For Each cell In Range("AM5:AM" & lRow)
    If cell.Value <= 12 Or cell.Value = "Finished" Then
        cell.EntireRow.Copy Sheets("Feuil4").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    End If
Next cell

End Sub


Well ... I guess it turned out to be more of a solution then a structure, still let us know if something is unclear.

Best regards,
Trowa
0