Excel copy all values from one main sheet to various other sheets if they are a certain colour - vba

Would really appreciate a solution to the below:
I am looking to have 8 sheets.
Main sheet that has all jobs, these are all currently sorted into the following colours :
Red - live
Green - invoiced/complete
Blue - quoted
Black - enquiry
Grey - dead/ lost
Purple - work in progress
Yellow - Retention
what i would like to do is keep the main sheet and have a sheet for each of the above. when the text becomes red for example i would like it to be transfered to the live sheet and vica versa for the rest. this should be in a macro
can anyone help?
Many thanks,

You say "when the text becomes red " so possibly this is a conditional format?
In any case, what you need to do is to attach code to the main sheet's Calculate event . This code should do the following
look at the activecell's color element that you mean (font, background, conditional formating, etc)
Based on that color, copy the entire row to the appropriate sheet
(Can you assume the sheets already exist?)
You will probably need a Select Case Statement. I would declare a worksheet variable and then SET it to the appropriate sheet in the select
and then
Activecell.entirerow.copy ws.cells(ws.rows.count,1).end(xlup).offset(1,0)
will copy the row to the desired sheet at the bottom of any existing rows.
Have a try and come back with code if you get stuck
EDIT: Sorry I missed the "click a button" part. You can ignore the bit about the sheets calculate event - just attach your code to the button. The only thing to worry about then is that you will need to run through all the used rows of the sheet, since there might be more than one coloured row when you click on the button.

Related

Excel - Highlight Rows based on look up value from another sheet

Hi I have an excel sheet, that has a column called as Company name
in another sheet there is there are couple of look ups.. i need to look up those and highlight them in different colors based on the look up list.
for example, in the above scenario, i need Company A Highligted in oone color and company C in another.
If highlighting is challgeng, i dont mind even having a seperate coloumn next to it that says, if it is a partner or competitor.
i tried the below formula under conditional formatting .. but doesnt work for different colours... it colors everything the same
=NOT(ISNA(VLOOKUP(B1,'Lookup List'!$A$2:$D$200,1,FALSE)))
Please try selecting Company Name column and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=COUNTIF('Lookup List'!$A:$A,B1)
Format..., select colour Fill (highlight) of your choice, OK, OK.
Then repeat with:
=COUNTIF('Lookup List'!$B:$B,B1)
with a different fill.
If every entry is one colour or the other then one CF rule is sufficient, with the other colour applied as standard fill.

Copying an Object Across a Workbook

I have a workbook which displays a little coloured box based on some input metrics from another worksheet within the workbook. I want to display these little coloured boxes in an additional worksheet in the workbook. Is there a way to copy a shape across worksheets so that the colour will still update with the metrics rather than using the code again for a separate worksheet?
I essentially want to display this textbox with the coloured boxes/arrows in another worksheet as well.
A pretty dirty way to do something like this would be the Indirect-Picture-Copy-Solution.
Asume the art is at Sheet1 B2:D8 then just input a picture in Sheet2 (the picture doesn't matter, just pick the first you can find)
While the Picture is selected input in the formula bar =Sheet1!B2:D8.
Hope that helps ;)
EDIT
For making it dynamically put in any module:
Public Function testing() As Range
Set testing = Range(Sheet1.Shapes("Dia 1").TopLeftCell, Sheet1.Shapes("Dia 1").BottomRightCell)
End Function
(Make sure to change the names to fit your workbook/sheet/shapes....-names)
Then define a name (I'll pick TETE for this example)
Refers to: =testing()
Then the picture-formula is: =TETE
Whenever the size or position changes, your picture fits to it... still not a good way to solve your problem (to my eye)
Funny fact: making the picture-formula directly to =testing() will just pop an error

How to highlight a cell when formula result from another sheet changes?

This is one that's been killing me and I've tried almost every solution on the Internet.
Here's background. I have an HR model that has each department broken out on separate tabs. I want to run an extract from our payroll system each payroll run and send highlight any updates individually. If someone's title or salary or status changes, I want to have that called out by highlighting the cell.
Each tab uses an INDEX/MATCH lookup to the extract tab to pull in the current information. What I want is if any value changes or is new(new hire, for example), highlight the cells.
I've played with Worksheet_Calculate and Worksheet_Change to no avail. Worksheet_Change doesn't fire because I'm not making the change directly on the sheet and Worksheet_Calculate doesn't have the Target object for to reference. I've tried the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim updatedCell As Range
Set updatedCell = Range(Target.Dependents.Address)
If Not Intersect(updatedCell, Range("A:A")) Is Nothing Then
updatedCell.Interior.ColorIndex = 3
End If
End Sub
The range I actually need evaluated is A7:R104 but I've been trying to get anything to work when linked to another sheet.
This works fine if formula of target cell is pointing to another cell on same sheet. The moment you point to one on another sheet it doesn't work. I've tried most of the solutions on here with no success. I've even tried putting the Worksheet_Change on the extract sheet and see if I can trigger it that way with no luck.
Is there a recommended solution to triggering a change to a cell for a formula linked to another sheet?
so I just saw this post, I don't know if you've found the solution or are still looking, but:
if you select a cell in sheet 3, you can then go to the home tab, go to "conditional formatting" -highlight cell rules - more rules (at the bottom) - and "use formulas to determine which cells to format" and then put your cursor in the formula box. now, select a cell in sheet 1 (click the sheet1 tab, and click a cell) and you'll notice it should populate the address for sheet1, and the cell u selected. now type <> after that cells address, then select sheet2 and a cell. then click format, and choose a fill color. then ok. if you go to conditional formatting and manage rules it will show there the rule / formula and which cells it applies to.
doing this i was able to select cell D10 in sheet 3, and make it an ugly green if cells in sheet1 and 2 didnt match (I picked which cells) you can also select a range of cells.
thusly, you can apply this rule to whatever dells you want, and if you record a macro of you setting this conditional formatting, you can manitpulate that macro to apply it to a bunch of different cells, and change the ranges. (using loops / variables)

Assigning a background color to a cell, given a condition on another cell

I am trying to create a formula in Microsoft Excel 2010 to accomplish the following algorithm:
If A1=10, then A2 has a background color of red.
I have basic knowledge of if/then statements in Excel, so I have this so far:
=IF(A1=10, x)
...where x would be the formula for changing the background color of the cell. However, after conducting some internet research on the subject, the consensus seems to be that I should instead use conditional formatting to accomplish this task. I have never used conditional formatting and am having trouble understanding how to utilize it so that a condition on one cell would affect another cell.
This is the conditional formatting screen that I am faced with:
So I guess I have two questions:
Is using conditional formatting the best way to accomplish this?
If so, how can I utilize it to assign a background color to a cell, given the truth of a condition on a different cell?
You can do it using conditional formatting, so you're on the right track. One thing I'm assuming here is that you want to format the cell to the right of the cell with the value - is that correct? If so, you actually don't need to use an if formula (though your logic is correct). In that dialog box, make the formula:
=A1=10
And then when you click OK, change the Applies to range by clicking on the little chart icon next to it and clicking cell B1. Then do apply, etc., close out the box and try typing 10 in A1. When you need to expand the range, you can just change that Applies to range to encompass everything you want affected. In the example below, cells B1:B26 will all change if 10 is entered in the cell directly to the left (column A).

Conditional Cell Contents on Grouping status

I'd like to have the value of a cell change if a specific set of grouped cells are hidden or not. Is there a worksheet change action for grouping and ungrouping cells? I can't seem to generate one with Macro Recorder; it doesn't seem to care if cells are hidden or unhidden in a group. Then, I can have a macro change the value of the cell in question - I presume easier than coding the cell itself.
Context:
There are 5 lines, one being a total, and the other 4 the accounts making up the total. There is a merged vertical cell across all 5 rows with the title. I like to hide the 4 accounts, but when I do, the merged title cell only diplays enough to fit into one line, so I'd like it to then revert to an abbreviation (which I would provide).
It's a bit esoteric and pointless, but any thoughts?
Solved. This post gives the essentials of what I needed:
http://www.ozgrid.com/forum/showthread.php?t=87457