VBA - Cut and paste based on cell colour

Taff

Board Regular
Joined
Mar 31, 2004
Messages
151
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi Guys,

looking for some help with some VBA code, which involves cutting and pasting a row dependent on a cell colour.

there are 2 actions required, which will lead me on to a few others that I will require to write, but any help with these would point me in the right direction to complete those.

Actions required:

1.Check column AQ, if any cell is the colour green, then copy the whole row and paste in a worksheet called Check. There will be several entries per session, I also need the rows pasted in the worksheet to run in a timely order, ie not copied over the last entry?

2. Check column AI and if the value in a cell is between 1.02 and 2.20, then copy whole row and paste into a worksheet called XGOA.


as always any assistance greatly appreciated.


Cheers

Taff
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Ok I got it sorted.

Yes there were blanks within the filtered area, once filled in - all worked fine.

Couldn't pick up the coloured cells, but the colour was generated by conditional formatting, based on a value, so I changed the filter criteria to pick up the cell value.

Thank you all, as always, for the help on this.

Cheers

Taff
 
Upvote 0
Filtering based on CF cell color works fine, but the color needs to match.

Filtering based on the cell value makes more sense, though.
 
Upvote 0
Hello Taff,

Wow! Alot happened here on this thread whilst I was watching football finals last night (and then sleeping it off!).

Looks like you're all sorted now. Mark858's question in post #11 ratifies why it is always a good idea to supply a sample of a workbook in the opening post. We can see what we're up against that way.


Someone discovered that 3 works the same as xlUp, and used that instead, just to prove they could be clever in obscuring their code. That's the Range.End(3)

I'm not sure exactly what shg implies with this comment, especially the part in bold italics, but I can assure you that there isn't a secret society of code writers who are obsessed with code secrecy.

In my case, its a simple case of not being a very good typist and I'd rather use an enumeration for the sake of brevity than type out all the associated text. Even with enumeration I'd rather type 3 than -4162 (xlUp). I'll use enumeration whenever I can remember the correct one to use! I could also be classed as lazy (not secretive)!

Its also good to see that you have made the effort to sort the minor problems out for yourself.

Anyway, good luck with it all and thanks for the feedback.

Cheerio,
vcoolio.
 
Upvote 0
Ok I got it sorted.

Yes there were blanks within the filtered area, once filled in - all worked fine.

If that is the case then probably the area of the currentregion wasn't what you thought it was.
Just for info the definition of the currentregion is

The current region is a range bounded by any combination of blank rows and blank columns.


so basically it is a range of contiguous data around the referenced cell. I also tend to agree with shg with his statement that it makes more sense to filter on the values (and I think that applies to most things in Excel if you have a choice).

Anyway happy you have it "sorted".
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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