Read cell content & ADD content + font properties *SOLVE

APOC [T.I.M.]

Board Regular
Joined
Jun 28, 2007
Messages
132
I use this to read cell content, add some text/characters (ie. [ and ]) and change the properties of the complete cell
Code:
Sub COMMENT()
Worksheets("DVD Lijssie").Activate
 If ActiveCell.Value <> 0 Then ' Change all in to ... ... ...
    ActiveCell.FormulaR1C1 = ActiveCell.Value & " " & "]" & " " & "["
    With ActiveCell.Font
        .Name = "Arial Narrow"
        .Size = 8
        .ColorIndex = 16
    End With
End If
End Sub
HOW can I change this vba-code so it leave's the content of the cell like it is and add some content with the use of let's say TexBox1 and ONLY use different font properties for the newely added content?

With kind regards, Tim
 
No you can't assign a value to a constant like that. I used a constant just for demonstration purposes.

However you can use a variable, eg:

Code:
Dim NewText as String
NewText =  " " & "[" & TextBox_ADD_Line.Value & "]" 
ActiveCell.Characters(Len(ActiveCell.Value) + 1).Insert NewText
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Solved: Read cell content & add input with font properti

Argh, darn... ofcourse
Thank you very much for your Time & Support.

Used (complete) code:
Code:
Private Sub UserForm_Activate()
CheckBox_ADD = False
CheckBox_Change.Value = True
CheckBox_Cleanup = False
'TextBox_ADD_Line
End Sub

Private Sub OK_Button_Form_Ctrl_W_Click()

If CheckBox_ADD.Value = True And CheckBox_Change.Value = False And CheckBox_Cleanup.Value = False Then
    TextBox_ADD_Line.SetFocus
        If TextBox_ADD_Line.Value = Empty Then
            ' Cancel = True
            MsgBox "Enter a value"
        Else
            With Worksheets("DVD Lijssie").Activate
                If ActiveCell.Value <> 0 Then ' Change all in to ... ... ...
                    Dim NewText As String
                    NewText = " " & "[" & TextBox_ADD_Line.Value & "]"
                    ActiveCell.Characters(Len(ActiveCell.Value) + 1).Insert NewText
                        With ActiveCell.Characters(Len(ActiveCell.Value) - Len(NewText) + 1, Len(NewText)).Font
                            .Name = "Arial Narrow"
                            .FontStyle = "Regular"
                            .Size = 8
                            .ColorIndex = 16
                        End With
                End If
            End With

        Unload Me
        End If
 Else
 ' NIKS / Nothing! / Just Continue...
End If

'Skip:
'Unload Me
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,949
Messages
6,127,888
Members
449,411
Latest member
AppellatePerson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top