Copy Paste help VBA if Cells are yellow paste to another sheet

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,074
Office Version
  1. 365
Platform
  1. Windows
Hi I am trying to copy any cells that are in yellow in Column B From Activesheet and paste it to another Workbook called "Mapping Table" to Lastrow.cells in column A. As I have a list of names on the Mapping Table workbook and need to add it in Column A to last entry.

Came across this and need a little help getting it to work thanks.

Code:
Sub Yellow()
Dim LR As Long, i As Long,LastRow
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    With Range("B" & i)
        If .Interior.ColorIndex = 6 Then
            .Copy Destination:= '<--- Need this to paste to workbook called "Mapping Table"  which there is only one tab sheets(1)

.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        End If
    End With
Next i
End Sub
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Assuming "Mapping Table" is open.
Code:
Copy Destination:=Workbooks("Mapping Table.xlsx").Sheets(1).Cells(Rows.Count, 1).End(xlup)(2)
 
Upvote 0
ok got it works great thanks. Yes that workbook is opened.

what it looks like now
Code:
Sub Yellow()
Dim LR As Long, i As Long
LR = Range("B" & Rows.count).End(xlUp).Row
For i = 1 To LR
    With Range("B" & i)
        If .Interior.ColorIndex = 6 Then
            .Copy Destination:=Workbooks("Mapping Table.xlsx").Sheets(1).Cells(Rows.count, 1).End(xlUp)(2)
        End If
    End With
Next i
End Sub
 
Upvote 0
You're welcome and thanks for the feedback.
regards, JLG
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top