Changing color in text boxes based on content

G

Guest

I have a spreadsheet with multiple cells and text boxes in some of the cells.
I want to be able to change the internal format of the cell based on the
information contained in the text box using a macro.

Also, is there a way to wrap the text box around the data in the cell like
the way Word can?

Any assistance would be appreciated.
oldybutgoody
 
J

JE McGimpsey

One way:

Public Sub CFTextBox1()
Dim nColorIndex As Long
Select Case Sheets("Sheet1").TextBoxes("Text Box 1").Text
Case "Option 1"
nColorIndex = 3
Case "Option 2"
nColorIndex = 5
Case "Option 3"
nColorIndex = 7
Case Else
nColorIndex = xlColorIndexNone
End Select
Range("A1").Interior.ColorIndex = nColorIndex
End Sub

Expand/change format to suit.

Your text boxes aren't "in some of the cells". Text boxes always exist
in the Drawing Layer in front of the cells. At best they can be
positioned to move and size with the underlying cells. XL can't wrap
text around them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top