Friday, 15 June 2012

excel - How to Change background Colour of Textbox Using a Button -



excel - How to Change background Colour of Textbox Using a Button -

i trying create excel file have macro changes fill colour of textbox. macro activated when user clicks on button (form control). new vba (and programming in general), , having problem writing code this. i've looked through other forums , tried applying read, seems solve problems using different code construction and/or syntax. logic code follows:

user clicks on button activate macro:

if textbox1 backcolor = rgb (191, 191, 191) textbox1 backcolor = rgb(242, 242, 242) else if textbox backcolor = rgb(242, 242, 242) textbox1 backcolor = rgb(191, 191, 191)

i figured simple task , yet i'm struggling it. help appreciated :)

thank you!

i've tried , should work you. attached button , worked fine:

if textbox1.backcolor = rgb(191, 191, 191) textbox1.backcolor = rgb(242, 242, 242) elseif textbox1.backcolor = rgb(242, 242, 242) textbox1.backcolor = rgb(191, 191, 191) end if

you utilize dot (.) object's properties, textbox1.backcolor.

excel vba colors textbox

No comments:

Post a Comment