PC Review


Reply
Thread Tools Rate Thread

Conditonally format a text box

 
 
Risky Dave
Guest
Posts: n/a
 
      30th Dec 2008
Hi,

I have a text box in a form that will contain one of three possible options:
1) blank
2) "Go"
3) "Stop"

I am happy enough with the look of the box as I have set it up when it is
blank but is it possible to conditionally format it so that the box
background goes red when "Stop" is the value and green when "go" is the value?

TIA

Dave
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      30th Dec 2008
1. Select the cell (or cells if there are more than one)

2. Click Format/Conditional Formatting from Excel's menu bar

3. Click the Add button so that 2 Conditions sections appear

4. Select "Formula Is" from the drop down box for both conditions

5. Put this formula in the empty field for Condition1... =A1="Go"
Click the Format button and choose a green color from Patterns tab

6. Put this formula in the empty field for Condition2... =A1="Stop"
Click the Format button and choose a red color from Patterns tab

Okay your way back to the worksheet.

NOTE: I used A1 for the cell reference, but you should use the address of
the selected cell (or the active cell address if more than one cell is
selected) in place of the A1 in both formulas.

--
Rick (MVP - Excel)


"Risky Dave" <(E-Mail Removed)> wrote in message
news:A5D30ADE-30CE-4EC4-9FF4-(E-Mail Removed)...
> Hi,
>
> I have a text box in a form that will contain one of three possible
> options:
> 1) blank
> 2) "Go"
> 3) "Stop"
>
> I am happy enough with the look of the box as I have set it up when it is
> blank but is it possible to conditionally format it so that the box
> background goes red when "Stop" is the value and green when "go" is the
> value?
>
> TIA
>
> Dave


 
Reply With Quote
 
Risky Dave
Guest
Posts: n/a
 
      30th Dec 2008
Rick,

Thanks for the response but I need to do this in a text box on a form using
VB.

Dave

"Rick Rothstein" wrote:

> 1. Select the cell (or cells if there are more than one)
>
> 2. Click Format/Conditional Formatting from Excel's menu bar
>
> 3. Click the Add button so that 2 Conditions sections appear
>
> 4. Select "Formula Is" from the drop down box for both conditions
>
> 5. Put this formula in the empty field for Condition1... =A1="Go"
> Click the Format button and choose a green color from Patterns tab
>
> 6. Put this formula in the empty field for Condition2... =A1="Stop"
> Click the Format button and choose a red color from Patterns tab
>
> Okay your way back to the worksheet.
>
> NOTE: I used A1 for the cell reference, but you should use the address of
> the selected cell (or the active cell address if more than one cell is
> selected) in place of the A1 in both formulas.
>
> --
> Rick (MVP - Excel)
>
>
> "Risky Dave" <(E-Mail Removed)> wrote in message
> news:A5D30ADE-30CE-4EC4-9FF4-(E-Mail Removed)...
> > Hi,
> >
> > I have a text box in a form that will contain one of three possible
> > options:
> > 1) blank
> > 2) "Go"
> > 3) "Stop"
> >
> > I am happy enough with the look of the box as I have set it up when it is
> > blank but is it possible to conditionally format it so that the box
> > background goes red when "Stop" is the value and green when "go" is the
> > value?
> >
> > TIA
> >
> > Dave

>
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      30th Dec 2008
Sorry, I didn't read your question carefully (my fault). Give this TextBox
Change event code a try...

Private Sub TextBox1_Change()
Select Case UCase(TextBox1.Text)
Case "GO"
TextBox1.BackColor = vbGreen
Case "STOP"
TextBox1.BackColor = vbRed
Case Else
TextBox1.BackColor = vbWhite
End Select
End Sub

--
Rick (MVP - Excel)


"Risky Dave" <(E-Mail Removed)> wrote in message
news:190046EE-6668-4A7C-81D3-(E-Mail Removed)...
> Rick,
>
> Thanks for the response but I need to do this in a text box on a form
> using
> VB.
>
> Dave
>
> "Rick Rothstein" wrote:
>
>> 1. Select the cell (or cells if there are more than one)
>>
>> 2. Click Format/Conditional Formatting from Excel's menu bar
>>
>> 3. Click the Add button so that 2 Conditions sections appear
>>
>> 4. Select "Formula Is" from the drop down box for both conditions
>>
>> 5. Put this formula in the empty field for Condition1... =A1="Go"
>> Click the Format button and choose a green color from Patterns tab
>>
>> 6. Put this formula in the empty field for Condition2... =A1="Stop"
>> Click the Format button and choose a red color from Patterns tab
>>
>> Okay your way back to the worksheet.
>>
>> NOTE: I used A1 for the cell reference, but you should use the address of
>> the selected cell (or the active cell address if more than one cell is
>> selected) in place of the A1 in both formulas.
>>
>> --
>> Rick (MVP - Excel)
>>
>>
>> "Risky Dave" <(E-Mail Removed)> wrote in message
>> news:A5D30ADE-30CE-4EC4-9FF4-(E-Mail Removed)...
>> > Hi,
>> >
>> > I have a text box in a form that will contain one of three possible
>> > options:
>> > 1) blank
>> > 2) "Go"
>> > 3) "Stop"
>> >
>> > I am happy enough with the look of the box as I have set it up when it
>> > is
>> > blank but is it possible to conditionally format it so that the box
>> > background goes red when "Stop" is the value and green when "go" is the
>> > value?
>> >
>> > TIA
>> >
>> > Dave

>>
>>


 
Reply With Quote
 
Risky Dave
Guest
Posts: n/a
 
      31st Dec 2008
Risk,

My thanks

"Rick Rothstein" wrote:

> Sorry, I didn't read your question carefully (my fault). Give this TextBox
> Change event code a try...
>
> Private Sub TextBox1_Change()
> Select Case UCase(TextBox1.Text)
> Case "GO"
> TextBox1.BackColor = vbGreen
> Case "STOP"
> TextBox1.BackColor = vbRed
> Case Else
> TextBox1.BackColor = vbWhite
> End Select
> End Sub
>
> --
> Rick (MVP - Excel)
>
>
> "Risky Dave" <(E-Mail Removed)> wrote in message
> news:190046EE-6668-4A7C-81D3-(E-Mail Removed)...
> > Rick,
> >
> > Thanks for the response but I need to do this in a text box on a form
> > using
> > VB.
> >
> > Dave
> >
> > "Rick Rothstein" wrote:
> >
> >> 1. Select the cell (or cells if there are more than one)
> >>
> >> 2. Click Format/Conditional Formatting from Excel's menu bar
> >>
> >> 3. Click the Add button so that 2 Conditions sections appear
> >>
> >> 4. Select "Formula Is" from the drop down box for both conditions
> >>
> >> 5. Put this formula in the empty field for Condition1... =A1="Go"
> >> Click the Format button and choose a green color from Patterns tab
> >>
> >> 6. Put this formula in the empty field for Condition2... =A1="Stop"
> >> Click the Format button and choose a red color from Patterns tab
> >>
> >> Okay your way back to the worksheet.
> >>
> >> NOTE: I used A1 for the cell reference, but you should use the address of
> >> the selected cell (or the active cell address if more than one cell is
> >> selected) in place of the A1 in both formulas.
> >>
> >> --
> >> Rick (MVP - Excel)
> >>
> >>
> >> "Risky Dave" <(E-Mail Removed)> wrote in message
> >> news:A5D30ADE-30CE-4EC4-9FF4-(E-Mail Removed)...
> >> > Hi,
> >> >
> >> > I have a text box in a form that will contain one of three possible
> >> > options:
> >> > 1) blank
> >> > 2) "Go"
> >> > 3) "Stop"
> >> >
> >> > I am happy enough with the look of the box as I have set it up when it
> >> > is
> >> > blank but is it possible to conditionally format it so that the box
> >> > background goes red when "Stop" is the value and green when "go" is the
> >> > value?
> >> >
> >> > TIA
> >> >
> >> > Dave
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If formula to conditonally format a cell Very Basic User Microsoft Excel Misc 1 6th Jul 2009 06:14 PM
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Microsoft Excel Worksheet Functions 6 2nd Jun 2009 08:14 PM
command button to open form selected conditonally? =?Utf-8?B?RGF2aWQgTmV3bWFyY2g=?= Microsoft Access Getting Started 5 17th Aug 2007 02:02 AM
conditonally formatting decimal places =?Utf-8?B?QmlnTWlrZUdhbGxhZ2hlcg==?= Microsoft Excel Misc 0 6th Apr 2006 06:08 PM
OL2K Force Format->Plain Text on Reply? (regardless of original format) foobar Microsoft Outlook Discussion 2 7th Jul 2003 12:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:29 AM.