Change an output based upon Conditional Formatting

%3CLINGO-SUB%20id%3D%22lingo-sub-1521344%22%20slang%3D%22en-US%22%3EChange%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1521344%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20a%20series%20of%20workbooks%20that%20utilize%20conditional%20formatting%20to%20highlight%20when%20a%20value%20exceeds%20a%20given%20tolerance%20range%20(cell%20background%20turns%20red).%20I%20would%20like%20to%20be%20able%20to%20change%20a%20text%20string%20on%20the%201st%20sheet%20of%20each%20workbook%20from%20one%20value%20to%20another%20if%20any%20cell%20in%20the%20same%20workbook%20is%20turned%20red%20by%20this%20conditional%20formatting.%20I've%20been%20searching%2C%20but%20can't%20seem%20to%20find%20anything%20that%20will%20accomplish%20this%2C%20even%20in%20VBA.%20What%20am%20I%20missing%3F%20Thanks%20in%20advance%20for%20your%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1521344%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1521478%22%20slang%3D%22en-US%22%3ERe%3A%20Change%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1521478%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F728336%22%20target%3D%22_blank%22%3E%40npfox1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20absence%20of%20seeing%20your%20actual%20workbooks%2C%20I%20can%20only%20offer%20a%20possible%20resolution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20this%3A%20in%20order%20for%20the%20conditional%20formatting%20to%20be%20working%2C%20to%20turn%20those%20cells%20to%20red%2C%20there%20has%20to%20be%20a%20formula%20or%20function%20that%20underlies%20that%20conditional%20formatting.%20Just%20use%20those%20same%20formulas%2Ffunctions%20as%20the%20basis%20for%20changing%20the%20text%20in%20the%20desired%20cells.%20Don't%20look%20for%20%22if%20red%2C%20then%20change%20text%22%3B%20rather%2C%20whatever%20those%20conditions%2Frules%20that%20cause%20the%20red%20should%20be%20able%20to%20be%20employed%20to%20change%20the%20text.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20am%20I%20missing%20something%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1521524%22%20slang%3D%22en-US%22%3ERe%3A%20Change%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1521524%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20the%20quick%20reply.%20I'm%20not%20sure%20what%20I%20can%20and%20can't%20share%20from%20a%20confidentiality%20standpoint.%20We%20utilize%20a%202%20workbook%20approach%20for%20each%20of%20our%20parts.%20The%20first%20workbook%20is%20a%20simple%20data%20table%20that%20is%20output%20by%20our%20CMM.%20The%20second%20workbook%20%22maps%22%20the%20data%20from%20the%20the%201st%20workbook's%20table%20into%20a%20more%20easily%20digestible%20format.%20Picture%20a%20workbook%20that%20attempts%20to%20visualize%20measurements%20around%20a%20part.%20The%20part%20is%20visualized%20by%20cross-sections%20on%20the%20page%2C%20and%20%22overlaid%22%20by%20the%20difference%20between%20the%20nominal%20value%20and%20the%20measured%20value%20of%20a%20feature%20or%20dimension.%20These%20values%20will%20be%20color-coded%20green%2C%20yellow%2C%20or%20red%20as%20they%20near%20the%20limits%20of%20the%20tolerance%20(via%20conditional%20formatting).%20A%20fourth%20conditional%20formatting%20rule%20will%20turn%20the%20cell%20of%20the%20value%20red%20to%20highlight%20that%20it%20is%20out%20of%20specification%20and%20manufacturing%20needs%20to%20halt%20until%20this%20is%20corrected.%20Some%20measurements%20may%20have%20a%20tolerance%20range%20of%20%2B%2F-%201mm%2C%20some%20may%20be%20%2B%2F-%201.5mm%2C%20etc.%20So%20there's%20not%20a%20hard-and-fast%20value%20around%20which%20I%20can%20write%20a%20single%20rule%20for%20the%20workbook.%20What%20I%20need%20is%20something%20that%20can%20search%20the%20workbook%20(typically%202%20or%203%20worksheets)%20and%20find%20any%20cells%20that%20were%20highlighted%20red%2C%20and%20then%20turn%20a%20%22text%20flag%22%20on%20the%201st%20worksheet%20from%20%22OK%20to%20run%22%20to%20%22Do%20not%20run!%22.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1521626%22%20slang%3D%22de-DE%22%3ERe%3A%20Change%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1521626%22%20slang%3D%22de-DE%22%3E...%20Maybe%20in%20VBA%3F%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20Sub%20Formatting()%20%3CBR%20%2F%3E%20Dim%20oWS%20As%20Worksheet%20%3CBR%20%2F%3E%20Dim%20i%20As%20Integer%20%3CBR%20%2F%3E%20'Loop%20across%20all%20worksheets%20%3CBR%20%2F%3E%20For%20i%20%3D%201%20To%20ThisWorkbook.Worksheets.Count%20%3CBR%20%2F%3E%20'Area%20for%20formatting%20With%20%3CBR%20%2F%3E%20ThisWorkbook.Worksheets(i).%20Range(%22C%3AC%2CE%3AE%22)%20%3CBR%20%2F%3E%20'Set%20%3CBR%20%2F%3E%20rule.%20FormatConditions.Add%20Type%3A%3DxlCellValue%2C%20Operator%3A%3DxlEqual%2C%20Formula1%3A%3D%22%22%22ja%22%22%22%20%3CBR%20%2F%3E%20.%20FormatConditions(.%20FormatConditions.Count).%20Interior.Color%20%3D%20vbGreen%20%3CBR%20%2F%3E%20End%20With%20Next%20i%20End%20Sub%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20Nikolino%20I%20know%20I%20know%20nothing%20%3CBR%20%2F%3E%20(Socrates)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1521987%22%20slang%3D%22en-US%22%3ERe%3A%20Change%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1521987%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F728336%22%20target%3D%22_blank%22%3E%40npfox1%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20wrote%3A%20%3CEM%3EThese%20values%20will%20be%20color-coded%20green%2C%20yellow%2C%20or%20red%20as%20they%20near%20the%20limits%20of%20the%20tolerance%20(via%20conditional%20formatting).%20A%20fourth%20conditional%20formatting%20rule%20will%20turn%20the%20cell%20of%20the%20value%20red%20to%20highlight%20that%20it%20is%20out%20of%20specification%20and%20manufacturing%20needs%20to%20halt%20until%20this%20is%20corrected.%20Some%20measurements%20may%20have%20a%20tolerance%20range%20of%20%2B%2F-%201mm%2C%20some%20may%20be%20%2B%2F-%201.5mm%2C%20etc.%20So%20there's%20not%20a%20hard-and-fast%20value%20around%20which%20I%20can%20write%20a%20single%20rule%20for%20the%20workbook.%26nbsp%3B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20from%20that%20reference%20to%20changing%20colors%20based%20on%20how%20close%20a%20particular%20measurement%20gets%20to%20the%20tolerance%20limits%2C%20I%20assume%20that%20there's%20also%20a%20table%20with%20those%20tolerance%20limits%2C%20(maybe%20with%20product%20specific%20values)%2C%20somewhere%20in%20this%20workbook.%20And%20the%20same%20for%20that%20%22fourth%20formatting%20rule%22--it%20has%20to%20be%20referring%20to%20a%20table%20of%20values......in%20order%20to%20do%20what%20you're%20describing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20even%20if%20there's%20not%20a%20single%20hard-and-fast%20value%2C%20there%20are%20values%20specified%20somewhere%20in%20there...just%20waiting%20to%20be%20put%20to%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1522057%22%20slang%3D%22de-DE%22%3ERe%3A%20Change%20an%20output%20based%20upon%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1522057%22%20slang%3D%22de-DE%22%3EYou%20are%20absolutely%20right%20....%20the%20script%20should%20serve%20as%20a%20starting%20point%20for%20vba%20...%20my%20failure%20not%20to%20write%20it%20down%20for%20that.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20I'm%20not%20a%20VBA%20professional%20...%20on%20the%20contrary%2C%20I%20am%20just%20as%20dependent%20on%20VBA%20as%20a%20beginner%20...%20which%20I%20am%20in%20VBA%20too.%20Try%20to%20help%20with%20my%20ignorance.%20If%20I%20have%20insulted%20someone%20with%20it%2C%20please%20forgive%20me%20...%20it%20was%20all%20done%20for%20good%20wants.%20Beginners%20help%20beginners%20...%20as%20far%20as%20possible%2C%20nothing%20more%20and%20nothing%20less.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20That's%20why%20I%20publicly%20express%20my%20ignorance%20under%20my%20name.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%20Nikolino%20%3CBR%20%2F%3E%20I%20know%20I%20don't%20know%20anything%20(Socrates)%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

We have a series of workbooks that utilize conditional formatting to highlight when a value exceeds a given tolerance range (cell background turns red). I would like to be able to change a text string on the 1st sheet of each workbook from one value to another if any cell in the same workbook is turned red by this conditional formatting. I've been searching, but can't seem to find anything that will accomplish this, even in VBA. What am I missing? Thanks in advance for your help!

5 Replies
Highlighted

@npfox1 

 

In the absence of seeing your actual workbooks, I can only offer a possible resolution.

 

It's this: in order for the conditional formatting to be working, to turn those cells to red, there has to be a formula or function that underlies that conditional formatting. Just use those same formulas/functions as the basis for changing the text in the desired cells. Don't look for "if red, then change text"; rather, whatever those conditions/rules that cause the red should be able to be employed to change the text.

 

Or am I missing something?

 

 

Highlighted

Thank you for the quick reply. I'm not sure what I can and can't share from a confidentiality standpoint. We utilize a 2 workbook approach for each of our parts. The first workbook is a simple data table that is output by our CMM. The second workbook "maps" the data from the the 1st workbook's table into a more easily digestible format. Picture a workbook that attempts to visualize measurements around a part. The part is visualized by cross-sections on the page, and "overlaid" by the difference between the nominal value and the measured value of a feature or dimension. These values will be color-coded green, yellow, or red as they near the limits of the tolerance (via conditional formatting). A fourth conditional formatting rule will turn the cell of the value red to highlight that it is out of specification and manufacturing needs to halt until this is corrected. Some measurements may have a tolerance range of +/- 1mm, some may be +/- 1.5mm, etc. So there's not a hard-and-fast value around which I can write a single rule for the workbook. What I need is something that can search the workbook (typically 2 or 3 worksheets) and find any cells that were highlighted red, and then turn a "text flag" on the 1st worksheet from "OK to run" to "Do not run!". @mathetes 

Highlighted
...maybe in VBA?

Sub Formatierung()
Dim oWS As Worksheet
Dim i As Integer
'Schleife über alle Tabellenblätter
For i = 1 To ThisWorkbook.Worksheets.Count
'Bereich für die Formatierung
With ThisWorkbook.Worksheets(i).Range("C:C,E:E")
'Regel setzen
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""ja"""
.FormatConditions(.FormatConditions.Count).Interior.Color = vbGreen
End With
Next i
End Sub

Nikolino
Ich weiß dass ich nichts weiß (Sokrates)
Highlighted

@npfox1 

You wrote: These values will be color-coded green, yellow, or red as they near the limits of the tolerance (via conditional formatting). A fourth conditional formatting rule will turn the cell of the value red to highlight that it is out of specification and manufacturing needs to halt until this is corrected. Some measurements may have a tolerance range of +/- 1mm, some may be +/- 1.5mm, etc. So there's not a hard-and-fast value around which I can write a single rule for the workbook. 

 

And from that reference to changing colors based on how close a particular measurement gets to the tolerance limits, I assume that there's also a table with those tolerance limits, (maybe with product specific values), somewhere in this workbook. And the same for that "fourth formatting rule"--it has to be referring to a table of values......in order to do what you're describing.

 

So even if there's not a single hard-and-fast value, there are values specified somewhere in there...just waiting to be put to work.

Highlighted
You are absolutely right .... the script should serve as a starting point for vba ... my failure not to write it down for that.

I'm not a VBA professional ... on the contrary, I am just as dependent on VBA as a beginner ... which I am in VBA too. Try to help with my ignorance. If I have insulted someone with it, please forgive me ... it was all done for good will. Beginners help beginners ... as far as possible, nothing more and nothing less.

That's why I publicly express my ignorance under my name.

Nikolino
I know I don't know anything (Socrates)