View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Changing color in text boxes based on content

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.

In article ,
oldybutgoody wrote:

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