Macro Copy Paste from one to another based on cell value
Closed
DPD
-
May 26, 2016 at 12:55 PM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - May 27, 2016 at 12:26 AM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - May 27, 2016 at 12:26 AM
Related:
- Macro Copy Paste from one to another based on cell value
- Excel macro to create new sheet based on value in cells - Guide
- Excel conditional formatting if another cell contains specific text ✓ - Excel Forum
- If cell contains text then return value multiple conditions ✓ - Excel Forum
- Macro to copy data from one workbook to another based on criteria ✓ - Excel Forum
- This message was deleted text copy and paste - Android Forum
1 response
vcoolio
Posts
1404
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 15, 2023
259
May 27, 2016 at 12:26 AM
May 27, 2016 at 12:26 AM
Hello DPD,
Your code appears to work just fine but if you are not happy with it, I've refined it a little for you as follows:-
I've altered line 11 a little just in case other users don't spell "YES" as you would like them to. So, "YES", "Yes" or "yes" should all work.
You can also change the sheet reference to Sheets("Phase II") if you prefer. I generally prefer to use the actual sheet code in a macro (I'm assuming that your sheet "Phase II" is Sheet2).
I hope that this helps.
Cheerio,
vcoolio.
Your code appears to work just fine but if you are not happy with it, I've refined it a little for you as follows:-
Sub Yes1() Application.ScreenUpdating = False Dim i As Integer Dim LastRow As Long LastRow = Cells(Rows.Count, "J").End(xlUp).Row For i = 2 To LastRow If UCase(Cells(i, 10).Value) = UCase("YES") Then Range(Cells(i, 1), Cells(i, 6)).Copy Sheet2.Range("A" & Rows.Count).End(3)(2) End If Next Application.CutCopyMode = False Application.ScreenUpdating = True Sheet2.Select End Sub
I've altered line 11 a little just in case other users don't spell "YES" as you would like them to. So, "YES", "Yes" or "yes" should all work.
You can also change the sheet reference to Sheets("Phase II") if you prefer. I generally prefer to use the actual sheet code in a macro (I'm assuming that your sheet "Phase II" is Sheet2).
I hope that this helps.
Cheerio,
vcoolio.