Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 17
Default a macro that Formats a textbox based on value in a cell

Have created textbox. The text in the textbox is driven from a formula.
Want the font in the textbox to depend on the value of a particular cell.
This particular cell can equal "RED", "GREEN", or "BLACK". Am attempting to
write a macro to solve this.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 751
Default a macro that Formats a textbox based on value in a cell

On Jun 6, 4:00 pm, txm49 wrote:
Have created textbox. The text in the textbox is driven from a formula.
Want the font in the textbox to depend on the value of a particular cell.
This particular cell can equal "RED", "GREEN", or "BLACK". Am attempting to
write a macro to solve this.



You can use the following event procedure to track the Change event
for the worksheet. This assumes that the cell you want to affect the
textbox is in A1 and that the textbox name is "Text Box 1". To be sure
of the name of the textbox click the textbox and look at the name box
left of the formula bar.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "A1" Then
Select Case UCase(Target.Value)
Case "RED"
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Font.Name = "Times New Roman"
Case "GREEN"
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Font.Name = "Arial"
Case "BLUE"
ActiveSheet.Shapes("Text Box 1").Select
Selection.Characters.Font.Name = "Tunga"
End Select
End If
Target.Select
End Sub

To install:
- Right click on the sheet tab. Choose View Code...
- It takes you to the VBA IDE. Paste the above code in the active
window.

HTH
Kostis Vezerides

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to go to cell based upon a calculation MARK M Excel Discussion (Misc queries) 7 November 30th 08 01:28 AM
How do I execute a macro based on the value of a cell in Excel? brettopp Excel Discussion (Misc queries) 12 June 17th 06 01:27 AM
Userform textbox number formats PhilM Excel Discussion (Misc queries) 2 June 7th 06 11:08 AM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Clear Cell based on event w/o macro? Paul987 Excel Worksheet Functions 2 October 27th 05 08:44 PM


All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"