Get best color match for font in a textbox that switches background color - vba

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have TextBox1 where I am using vba to switch background color based on contents that appear in it. I currently have one color for the fonts.

One issue is that the color is not visible on some of the background.

I have used various font colors and having same issue.

My only option here is to manually set the font color to match the various background using the same condition I used to switch the background colors.

Before I do so, is it possible to get the best color blend for the stated situation above?

I mean a vba code to determine which color will be visible on a background?

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I don't understand the line you posted. Should I place that alone in the textbox?
I think .ColorIndex = .xlColorIndexAutomatic should be in the font section of your cell selection,

something is nagging me about textboxes, not something I have used for a long time
 
Upvote 0
I will use the conditions to set the colors as I have said before.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,537
Members
449,088
Latest member
RandomExceller01

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