ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Changing color in text boxes based on content (https://www.excelbanter.com/excel-discussion-misc-queries/163161-changing-color-text-boxes-based-content.html)

oldybutgoody

Changing color in text boxes based on content
 
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


JE McGimpsey

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



All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com