Copy Each row if Back Colour Equals Green

healey21

Well-known Member
Joined
Dec 22, 2009
Messages
900
Can anyone tell me how to copy each row of data if A cell in this range has a green colour. Range("E6:BN5000") to a new sheet.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
One way to try, save your workbook first.

To do it manually ~ I am assuming your data starts in row 6.

First do this ~
copy this formula
=OFFSET($E$5,1,0,COUNTA(OFFSET($A$5,1,0,9999)),62)

In the formulas menu, click name manager, Click new, in the name box type in green for the name. in the refers to box paste the formula you copied. Click OK

Now you need a header row above your data, then you would select that header row and Click Auto Filter in the data menu.

Next step is to filter in column A by colour, you would click the triangle and select filter by colour, select the green.

Next press Alt and G, type in green, then copy (the area automatically selected), then select your destination you wish to paste to, select Paste Special, Values, OK.

If you wish to retain formulas and formats instead of values, just click Paste instead of Paste Special.

Would be easier to do it with a macro. If you wish a macro more details would be needed.
e.g. Sheet names, data range, cell to copy to and colour index of the green you wish to filter.

Cheers
 
Upvote 0
Thank you for the reply.

Shown below is a sample of my sheet. What I am aiming for is to copy each row that is coloured vbGreen and the contents of Column A to BN of that row to a sheet named Results is Range("E6:BN5000"). VBA would be excellent if you can help me.

Results


<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Calibri,Arial; FONT-SIZE: 11pt" border=1 cellSpacing=0 cellPadding=0><COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD> </TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD><TD>G</TD><TD>H</TD><TD>I</TD><TD>J</TD></TR><TR style="HEIGHT: 113px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">1</TD><TD style="FONT-FAMILY: Arial; COLOR: #808080; FONT-SIZE: 12pt; FONT-WEIGHT: bold" colSpan=4> </TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Alpha</TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Bravo</TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Charlie</TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Delta</TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Echo</TD><TD style="TEXT-ALIGN: center; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Foxtrot</TD></TR><TR style="HEIGHT: 15px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">2</TD><TD style="TEXT-ALIGN: left; BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Name</TD><TD style="TEXT-ALIGN: left; BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Depart</TD><TD style="TEXT-ALIGN: left; BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Place</TD><TD style="TEXT-ALIGN: left; BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold">Employee</TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD><TD style="BACKGROUND-COLOR: #333333; FONT-FAMILY: Arial; COLOR: #ffffff; FONT-SIZE: 9pt; FONT-WEIGHT: bold"> </TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">3</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt">Mark</TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #008000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #ff0000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #008000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #ff0000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">1</TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">4</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt">Andy</TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #008000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">4</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">5</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt">Alan</TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #ff0000; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">6</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt">Miles</TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD></TR><TR style="HEIGHT: 16px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">7</TD><TD style="TEXT-ALIGN: left; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt">Jess</TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 9pt"> </TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #ffffcc; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">2</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #00b050; FONT-FAMILY: Arial; COLOR: #333333; FONT-SIZE: 10pt; FONT-WEIGHT: bold">3</TD></TR></TBODY></TABLE>


Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
 
Upvote 0
Hi healey21,

Your sheet is not how I envisaged it from your first post. Your first post intimated to me that the green cells were in Column A

Are the green cells only in columns E through J?
What is the name of the first sheet to be copied from?
If any row has a green cell ~ You wish to copy that row, is that correct?

You will need headers in all the columns from column A to BN in row 2 even if they are just consecutive numbers.

From the sheet you posted you can forget the manual way I instructed as it would not be applicable.

Cheers
 
Upvote 0
Hi,

Thanks for taking the time to look at helping. In my first post I did place the letter A accidently in capitals but also stated the Range("E6:BN5000"). What I have done is set up some code to use an offset and add some text in a column so I can then filter so I can then copy the filtered data into a new sheet.

So this is now working for me.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,153
Members
452,891
Latest member
JUSTOUTOFMYREACH

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