Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
mixed formatting in same cell with VBA
Is it possible to have two different text formats in the same cell when using
VBA? For example, I am using the textboxes from a userform to fill a cell: WS.Cells(1, 1).Value = Me.txtFirst.Value & Me.txtMiddle.Value & Me.txtLast.Value I want to make the font format of one of the values different from the others. For example, so the end result would be: txtFirst <btxtMiddle</b txtLast. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
mixed formatting in same cell with VBA
You sure you wouldn't want spaces between each part of the name?
In any case, maybe this'll give you a start: Option Explicit Private Sub CommandButton1_Click() With Worksheets("sheet1").Range("a1") .Value = Me.TextBox1.Value & Me.TextBox2.Value & Me.TextBox3.Value With .Characters(Start:=Len(Me.TextBox1.Value) + 1, _ Length:=Len(Me.TextBox3.Value)).Font .FontStyle = "Bold" End With End With End Sub Horatio J. Bilge, Jr. wrote: Is it possible to have two different text formats in the same cell when using VBA? For example, I am using the textboxes from a userform to fill a cell: WS.Cells(1, 1).Value = Me.txtFirst.Value & Me.txtMiddle.Value & Me.txtLast.Value I want to make the font format of one of the values different from the others. For example, so the end result would be: txtFirst <btxtMiddle</b txtLast. -- Dave Peterson |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
mixed formatting in same cell with VBA
Just a note, this kind of formatting won't work with formulas and won't work
with numbers. So just in case the user types numbers, it may be best to format the cells as text before entering the concatenated value into that cell: Option Explicit Private Sub CommandButton1_Click() With Worksheets("sheet1").Range("a1") .NumberFormat = "@" 'text .Value = Me.TextBox1.Value & Me.TextBox2.Value & Me.TextBox3.Value With .Characters(Start:=Len(Me.TextBox1.Value) + 1, _ Length:=Len(Me.TextBox3.Value)).Font .FontStyle = "Bold" End With End With End Sub Horatio J. Bilge, Jr. wrote: Is it possible to have two different text formats in the same cell when using VBA? For example, I am using the textboxes from a userform to fill a cell: WS.Cells(1, 1).Value = Me.txtFirst.Value & Me.txtMiddle.Value & Me.txtLast.Value I want to make the font format of one of the values different from the others. For example, so the end result would be: txtFirst <btxtMiddle</b txtLast. -- Dave Peterson |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
mixed formatting in same cell with VBA
Thanks. I've been trying to figure this out for a long time. You're right, I
did have spaces between the values, but I forgot to put them in when I typed my post... ..Value = Me.txtFirst.Value & " " & Me.txtMiddle.Value & " " & Me.txtLast.Value "Dave Peterson" wrote: Just a note, this kind of formatting won't work with formulas and won't work with numbers. So just in case the user types numbers, it may be best to format the cells as text before entering the concatenated value into that cell: Option Explicit Private Sub CommandButton1_Click() With Worksheets("sheet1").Range("a1") .NumberFormat = "@" 'text .Value = Me.TextBox1.Value & Me.TextBox2.Value & Me.TextBox3.Value With .Characters(Start:=Len(Me.TextBox1.Value) + 1, _ Length:=Len(Me.TextBox3.Value)).Font .FontStyle = "Bold" End With End With End Sub Horatio J. Bilge, Jr. wrote: Is it possible to have two different text formats in the same cell when using VBA? For example, I am using the textboxes from a userform to fill a cell: WS.Cells(1, 1).Value = Me.txtFirst.Value & Me.txtMiddle.Value & Me.txtLast.Value I want to make the font format of one of the values different from the others. For example, so the end result would be: txtFirst <btxtMiddle</b txtLast. -- Dave Peterson |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
mixed formatting in same cell with VBA
Make sure you adjust the start to add that extra space character, too.
Horatio J. Bilge, Jr. wrote: Thanks. I've been trying to figure this out for a long time. You're right, I did have spaces between the values, but I forgot to put them in when I typed my post... .Value = Me.txtFirst.Value & " " & Me.txtMiddle.Value & " " & Me.txtLast.Value "Dave Peterson" wrote: Just a note, this kind of formatting won't work with formulas and won't work with numbers. So just in case the user types numbers, it may be best to format the cells as text before entering the concatenated value into that cell: Option Explicit Private Sub CommandButton1_Click() With Worksheets("sheet1").Range("a1") .NumberFormat = "@" 'text .Value = Me.TextBox1.Value & Me.TextBox2.Value & Me.TextBox3.Value With .Characters(Start:=Len(Me.TextBox1.Value) + 1, _ Length:=Len(Me.TextBox3.Value)).Font .FontStyle = "Bold" End With End With End Sub Horatio J. Bilge, Jr. wrote: Is it possible to have two different text formats in the same cell when using VBA? For example, I am using the textboxes from a userform to fill a cell: WS.Cells(1, 1).Value = Me.txtFirst.Value & Me.txtMiddle.Value & Me.txtLast.Value I want to make the font format of one of the values different from the others. For example, so the end result would be: txtFirst <btxtMiddle</b txtLast. -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Formatting; finding numerical data in mixed text. | Excel Discussion (Misc queries) | |||
Conditional Formatting in for Cells with Mixed Dates and Text | Excel Worksheet Functions | |||
Mixed Cell Formatiing | Setting up and Configuration of Excel | |||
Mixed data types in a cell | Excel Discussion (Misc queries) | |||
Mixed Cell | Excel Worksheet Functions |