PDA

View Full Version : Macro which copy cells if other cell have specific value



alicjon
09-21-2014, 07:01 AM
Hi guys,

I need help with macro
I need macro, that will be copy value from cells in column B from sheet1 to first avaible (free) cell in column D of sheet2 under condition that in cell in column F of sheet1 (in that row) is value "yes". After that i need to remove that row in sheet1. I have something like this at this moment:

Sub ddd()


Dim OstW As Long
Dim kom As Excel.Range

Application.ScreenUpdating = False

With Sheets("Sheet1")
OstW = .Cells(Rows.Count, "F").End(xlUp).Row

For Each kom In .Range("F4:F" & OstW)
If kom.Value = "yes" Then
Range("B4:B").Copy

With Sheets("Sheet2")
Range("D5:D").PasteSpecial
Paste = xlPasteValues

End With

.Rows(kom.Row).Delete
End If
Next kom

End With

Application.ScreenUpdating = True

End Sub
I hope you can help me.
Please!

VoG
09-21-2014, 09:44 AM
Cross posted http://www.mrexcel.com/forum/excel-questions/806846-macro-copy-cells-under-condition.html