ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   textbox backgroundcolor (https://www.excelbanter.com/excel-programming/401148-textbox-backgroundcolor.html)

Frank M

textbox backgroundcolor
 
for my application i created a form with a textbox on it. With a code the
value of the searched cell will be displayed in the textbox. However i also
want the textbox.backgroundcolor to be the same as the cell color. So
something like TextBox1.backgroundcolor = ActiveCell.interior.Colorindex.

Problem is that excel uses the colorindex 3 for the color red, and visual
basic uses &H000000FF& for that same color. Is there a way so that i can
create this?

Peter T

textbox backgroundcolor
 
TextBox1.BackColor = ActiveCell.Interior.Color

In passing -
myColorIndex = 3
myLongRGB = ActiveWorkbook.Colors(myColorIndex)

Regards,
Peter T

"Frank M" wrote in message
...
for my application i created a form with a textbox on it. With a code the
value of the searched cell will be displayed in the textbox. However i

also
want the textbox.backgroundcolor to be the same as the cell color. So
something like TextBox1.backgroundcolor = ActiveCell.interior.Colorindex.

Problem is that excel uses the colorindex 3 for the color red, and visual
basic uses &H000000FF& for that same color. Is there a way so that i can
create this?




joel

textbox backgroundcolor
 
Use color instead of colorindex. the code below returns 255 for the variable
a.

Range("A1").Interior.ColorIndex = 3
a = Range("A1").Interior.Color

"Frank M" wrote:

for my application i created a form with a textbox on it. With a code the
value of the searched cell will be displayed in the textbox. However i also
want the textbox.backgroundcolor to be the same as the cell color. So
something like TextBox1.backgroundcolor = ActiveCell.interior.Colorindex.

Problem is that excel uses the colorindex 3 for the color red, and visual
basic uses &H000000FF& for that same color. Is there a way so that i can
create this?


Frank M

textbox backgroundcolor
 
Thnx, it works great!

"Joel" wrote:

Use color instead of colorindex. the code below returns 255 for the variable
a.

Range("A1").Interior.ColorIndex = 3
a = Range("A1").Interior.Color

"Frank M" wrote:

for my application i created a form with a textbox on it. With a code the
value of the searched cell will be displayed in the textbox. However i also
want the textbox.backgroundcolor to be the same as the cell color. So
something like TextBox1.backgroundcolor = ActiveCell.interior.Colorindex.

Problem is that excel uses the colorindex 3 for the color red, and visual
basic uses &H000000FF& for that same color. Is there a way so that i can
create this?



All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com