Add text in red with userForm

KlaasE

New Member
Joined
Nov 4, 2019
Messages
37
Hi folks,

For a worksheet I'm making a comment form. What it does is simply add some text to a cell the user selects. What I've been unable to figure out is how I make only the added text in red, while the rest stays the same (black). Right now it add's the text from a Textbox to a cell. It seems like a simple question but I just can't find the answer yet on the forums.
The code I'm using right now:
Code:
Private Sub CommentButton_Click()
ActiveSheet.Unprotect Password:="***"
Set YourRange = Application.InputBox(Prompt:="Select Range", Type:=8)
YourRange.Select
ActiveCell.Value = ActiveCell.Value & vbNewLine & CommentTextBox.Value
ActiveSheet.Protect Password:="***"
End Sub

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about
Code:
Private Sub CommentButton_Click()
    Dim YourRange As Range
    Dim Lngth As Long
    
    ActiveSheet.Unprotect Password:="***"
    Set YourRange = Application.InputBox(Prompt:="Select Range", Type:=8)
    Lngth = Len(YourRange.Value)
    YourRange.Value = YourRange.Value & vbNewLine & CommentTextBox.Value
    YourRange.Characters(Lngth + 1).Font.Color = vbRed
    ActiveSheet.Protect Password:="***"
End Sub
 
Upvote 0
Perfect, thanks!
I tried to store the whole CommentTextBox in a variable but couldn't get it working.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,171
Members
452,615
Latest member
bogeys2birdies

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