Using If in Visual Basic to change cell's Zoom based on text color

%3CLINGO-SUB%20id%3D%22lingo-sub-2289059%22%20slang%3D%22en-US%22%3EUsing%20If%20in%20Visual%20Basic%20to%20change%20cell's%20Zoom%20based%20on%20text%20color%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289059%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20Excel%202016%20on%20a%20Windows%20laptop.%3C%2FP%3E%3CP%3EI%20want%20to%20use%20the%20If%20function%20in%20Visual%20Basic%20to%20change%20a%20cell's%20zoom%20based%20on%20the%20text%20color%20of%20that%20cell.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example.%20If%20the%20cell%20has%20red%20text%2C%20the%20zoom%20should%20be%20to%20the%20selection.%20If%20the%20text%20color%20is%20black%20the%20zoom%20should%20be%20at%20100%25.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20a%20macro%2C%20the%20cell's%20color%20is%20shown%20as%20a%20%22with%22%20statement.%20For%20example%2C%20a%20red%20text%20would%20be%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%22With%20Selection.Font%3CBR%20%2F%3E.Color%20%3D%20-16776961%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3EEnd%20With%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDon't%20know%20how%20I%20would%20phrase%20this%20in%20Visual%20Basic.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EFrank%20Drucker%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2289059%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

I have Excel 2016 on a Windows laptop.

I want to use the If function in Visual Basic to change a cell's zoom based on the text color of that cell.

 

For example. If the cell has red text, the zoom should be to the selection. If the text color is black the zoom should be at 100%.

 

Using a macro, the cell's color is shown as a "with" statement. For example, a red text would be                

"With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With

 

Don't know how I would phrase this in Visual Basic.

 

Thanks,

Frank Drucker

0 Replies