Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

copy and paste based on certain conditions

i need a simple vba code. I hope someone can help me.
So, I want to copy the range B2:E6 and leave some cells marked with a special condition. I created a rule in cells A2:A6 with the value Y / X. In the end, I want to paste the value B2:E6 in the range F9:I13 only if the value is Y.

I am attaching the following image to make it easier for you to understand.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help will be great. And sorry my english is bad.

>Solution :

Maybe this can get you started

Sub Macro1()
Dest = 8
For Row = 1 To 6
    If Cells(Row, 1) <> "x" Then
        Range(Cells(Row, 2), Cells(Row, 5)).Select
        Selection.Copy
        Cells(Dest, 6).Select
        ActiveSheet.Paste
    End If
    Dest = Dest + 1
Next Row
End Sub
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading