• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy rows further up on the same spreasheet

Evie76

New Member
I am trying to copy rows that have been inputted with a name in coloum C (data starts at C32). The code i have is below, it works fine if i am copying to a differenct sheet but i need to copy the rows c18:N26. Can anyone help?


Code:
Private Sub CommandButton1_Click()
Dim lr As Long, lr2 As Long, r As Long
Dim ws1 As Worksheet
Application.ScreenUpdating = False

Set ws1 = Sheets("Interface")

lr = ws1.Cells(Rows.Count, "d").End(xlUp).Row

For r = lr To 2 Step -1
    lr2 = ws1.Cells(Rows.Count, "c").End(xlUp).Row + 1

    If ws1.Range("c" & r).Value = "Donna" Or _
        ws1.Range("c" & r).Value = "Laura" Or _
ws1.Range("c" & r).Value = "Sam" Or _
   ws1.Range("c" & r).Value = "Sophie" Or _
   ws1.Range("c" & r).Value = "Yvonne" Or _
   ws1.Range("c" & r).Value = "Matt" Or _
   ws1.Range("c" & r).Value = "Dan" Then
 
        ws1.Rows(r).Copy Destination:=ws1.Range("c18:n26" & lr2)
    End If
Next r
Application.ScreenUpdating = True
End Sub
 

vletm

Excel Ninja
Evie76
Your I am trying to copy rows that ...
Could You upload a sample Excel file which would show?
... what and how should happen with Your sample data?
 
Top