PC Review


Reply
Thread Tools Rate Thread

Conditional formatting in text boxes

 
 
Roger on Excel
Guest
Posts: n/a
 
      17th Dec 2009
I have textboxes on a userform.

The text boxes read (and write) to cells A1:A60

Adjacent to these cells I have a comments column which is filled in for
particular rows

Depending on whether the adjacent cell in column B has an entry, is there a
way to make the textboxes change their font attributes? For example, become
BOLD when there is a comment.

Can anyone help?


 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      17th Dec 2009
You should have posted your code..Within your loop add a line something like
the below..

Dim intCount as Integer
For intCount = 1 To 60
Me.Controls("Textbox" & intCount).Font.Bold = _
Not (Range("A" & intCount).Offset(, 1).Text = "")
Next

--
Jacob


"Roger on Excel" wrote:

> I have textboxes on a userform.
>
> The text boxes read (and write) to cells A1:A60
>
> Adjacent to these cells I have a comments column which is filled in for
> particular rows
>
> Depending on whether the adjacent cell in column B has an entry, is there a
> way to make the textboxes change their font attributes? For example, become
> BOLD when there is a comment.
>
> Can anyone help?
>
>

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Dec 2009
Since you didn't post any code you probably have lots of options. Do you
change the values of the cells using the Userform interface or the worksheet?


If the worksheet and you didn't change the default Textbox names, then you
probably want to setup a Worksheet_Change Event call a sub like this:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = "B" Then
Call TextBoxBolding(Target.Row)
End If

End Sub

Sub TextBoxBolding(rw As Long)
Me.Controls("Textbox" & rw).Font.Bold = Not Cells(rw, "B").Text = ""
End Sub

Or you could put Jacob's code in your Userform_Intialize Event.

Private Sub UserForm_Initialize()

Dim i As Long

For i = 1 To 60
Me.Controls("Textbox" & i).Font.Bold = Not Cells(i, "B").Text = ""
Next i

End Sub

Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"Roger on Excel" wrote:

> I have textboxes on a userform.
>
> The text boxes read (and write) to cells A1:A60
>
> Adjacent to these cells I have a comments column which is filled in for
> particular rows
>
> Depending on whether the adjacent cell in column B has an entry, is there a
> way to make the textboxes change their font attributes? For example, become
> BOLD when there is a comment.
>
> Can anyone help?
>
>

 
Reply With Quote
 
Roger on Excel
Guest
Posts: n/a
 
      17th Dec 2009
Dear Jacob,

Thankyou for the code - it works very nicely.

I was able to modify it for my purposes relatively easily. Apologies for
not including the code I am using.

I have a question - how does one change other text attributes using this
code? for example if I want to change the the color to red or even change the
font?

Best regards,

Roger

"Jacob Skaria" wrote:

> You should have posted your code..Within your loop add a line something like
> the below..
>
> Dim intCount as Integer
> For intCount = 1 To 60
> Me.Controls("Textbox" & intCount).Font.Bold = _
> Not (Range("A" & intCount).Offset(, 1).Text = "")
> Next
>
> --
> Jacob
>
>
> "Roger on Excel" wrote:
>
> > I have textboxes on a userform.
> >
> > The text boxes read (and write) to cells A1:A60
> >
> > Adjacent to these cells I have a comments column which is filled in for
> > particular rows
> >
> > Depending on whether the adjacent cell in column B has an entry, is there a
> > way to make the textboxes change their font attributes? For example, become
> > BOLD when there is a comment.
> >
> > Can anyone help?
> >
> >

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Dec 2009
Put this in your Userform Intialize Event

Private Sub UserForm_Initialize()

Dim i As Long

For i = 1 To 1
With Me.Controls("Textbox" & i)
.Font.Bold = Not Cells(i, "B").Text = ""
.BackColor = 255
.Font.Name = "Tahoma"
End With
Next i

End Sub
--
Cheers,
Ryan


"Roger on Excel" wrote:

> Dear Jacob,
>
> Thankyou for the code - it works very nicely.
>
> I was able to modify it for my purposes relatively easily. Apologies for
> not including the code I am using.
>
> I have a question - how does one change other text attributes using this
> code? for example if I want to change the the color to red or even change the
> font?
>
> Best regards,
>
> Roger
>
> "Jacob Skaria" wrote:
>
> > You should have posted your code..Within your loop add a line something like
> > the below..
> >
> > Dim intCount as Integer
> > For intCount = 1 To 60
> > Me.Controls("Textbox" & intCount).Font.Bold = _
> > Not (Range("A" & intCount).Offset(, 1).Text = "")
> > Next
> >
> > --
> > Jacob
> >
> >
> > "Roger on Excel" wrote:
> >
> > > I have textboxes on a userform.
> > >
> > > The text boxes read (and write) to cells A1:A60
> > >
> > > Adjacent to these cells I have a comments column which is filled in for
> > > particular rows
> > >
> > > Depending on whether the adjacent cell in column B has an entry, is there a
> > > way to make the textboxes change their font attributes? For example, become
> > > BOLD when there is a comment.
> > >
> > > Can anyone help?
> > >
> > >

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      17th Dec 2009
Correction,

Private Sub UserForm_Initialize()

Dim i As Long

For i = 1 To 60
With Me.Controls("Textbox" & i)

' bold or unbold font
.Font.Bold = Not Cells(i, "B").Text = ""

' change font color
.BackColor = 255

' change font name
.Font.Name = "Tahoma"
End With
Next i

End Sub


Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"Roger on Excel" wrote:

> Dear Jacob,
>
> Thankyou for the code - it works very nicely.
>
> I was able to modify it for my purposes relatively easily. Apologies for
> not including the code I am using.
>
> I have a question - how does one change other text attributes using this
> code? for example if I want to change the the color to red or even change the
> font?
>
> Best regards,
>
> Roger
>
> "Jacob Skaria" wrote:
>
> > You should have posted your code..Within your loop add a line something like
> > the below..
> >
> > Dim intCount as Integer
> > For intCount = 1 To 60
> > Me.Controls("Textbox" & intCount).Font.Bold = _
> > Not (Range("A" & intCount).Offset(, 1).Text = "")
> > Next
> >
> > --
> > Jacob
> >
> >
> > "Roger on Excel" wrote:
> >
> > > I have textboxes on a userform.
> > >
> > > The text boxes read (and write) to cells A1:A60
> > >
> > > Adjacent to these cells I have a comments column which is filled in for
> > > particular rows
> > >
> > > Depending on whether the adjacent cell in column B has an entry, is there a
> > > way to make the textboxes change their font attributes? For example, become
> > > BOLD when there is a comment.
> > >
> > > Can anyone help?
> > >
> > >

 
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
Conditional Formating: Text Boxes, New Record Paul-AZ-TX Microsoft Access Form Coding 2 19th Jun 2009 06:23 PM
Conditional text boxes on Form Anand Microsoft Excel Programming 1 21st Jun 2008 12:32 PM
Formatting text boxes Kristina Microsoft Word Document Management 1 7th Apr 2008 01:12 AM
Conditional Formatting of text effecting formatting of background =?Utf-8?B?SEFI?= Microsoft Access Reports 6 25th Mar 2008 06:23 PM
Check Boxes and Conditional Formatting =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 2 29th Nov 2004 07:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:53 PM.