Code for TEXT gets Bold When its get typed anywhere

bobby786

Board Regular
Joined
Apr 24, 2014
Messages
87
Office Version
  1. 2016
Platform
  1. Windows
Dear All Experts.

Please forgive my english as its not my native language. I am in a situation where i want to get a certain word " Pending" as bold and italic whenever i type it on that particular sheet. All the text contains in one cell with many other words , but everytime i type pending i have to manually do BOLD and ITALIC within the cell which is time taking and very easy to forget do it.
Is there any way to make it automatic and dynamic in a way that on that worksheet wherever i type " pending " without quotes it will get BOLD and ITALICS automatically .

Below is my text which is in C403 is the last data entry in my sheet starting from cell A01 .

Apple box Order-6 2000pcs pcs pending ,PI 2019-12-20 ,PO , Deposit pending , dispatch details pending , Artwork done ,


I hope to get help from this forum.

Regards
Bobby
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Is it possible that you have words that contain "pending" in it? like "depending"?
If the answer is NO then try this:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.CountLarge <> 1 Then Exit Sub
Dim i As Long, x As Long
        With Target
        i = 1
        Do
            x = InStr(i, .Value, "pending", vbTextCompare)
            If x = 0 Then Exit Do
            .Characters(x, 7).Font.Bold = True
            .Characters(x, 7).Font.Italic = True
            i = x + 6
        Loop
        End With
        
End Sub
This is an Event Procedure, you need to put it in the code module of the sheet (say sheet1).
So copy the code > open sheet1 > right click sheet1 tab > select View Code > paste the code.
The Sub Worksheet_Change is triggered whenever you exit a cell after you changed its content.

FYI, the best way to post a range/table is by using XL2BB add-in, you can download it by clicking the XL2BB icon in the reply window.
 
Upvote 0
Dear
Akuini

Good Stuff. Its working perfect. Thank you

about XL2BB , yes i had that already , next time will be more careful about it

Regards
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,164
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