• 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 & Paste in Trick Required in VBA

Hi All,

I have 2 sheets in my excel "Copy" & "Paste"
While Pasting if "E) No Requirement" if this reason comes that column should be paste as blank.

is there is any code in VBA can you help on same.
sample file enclosed.

Thanks
 

Attachments

  • Book2.xlsx
    9.7 KB · Views: 2
Code:
Option Explicit

Sub foo()
    Dim s1 As Worksheet, s2 As Worksheet
    Dim i As Long, lr As Long
    Set s1 = Sheets("Copy")
    Set s2 = Sheets("Paste")
    Application.ScreenUpdating = False
    lr = s1.Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        If s1.Range("A" & i) <> "No Requirement" Then
            s2.Range("A" & i) = s1.Range("A" & i)
        End If
        Mext i
    Application.ScreenUpdating = True
        MsgBox "Action Complete"
End Sub
 
Back
Top