Aug 07 2024 01:21 PM
I'm trying to have Excel bold the text after "MM " in a cell. I would like to have it do this for the entire range. Right now I'm doing it manually. Here is an image of my worksheet.
Any help would be appreciated.
Thank you.
Scott
Aug 07 2024 01:40 PM
The following will on;y work in the desktop version of Excel for Windows or Mac.
Press Alt+F11 to activate the Visual Basic Editor.
Select Insert > Module.
Copy the following code into the new module:
Sub BoldAfterMM()
Dim c As Range
Dim p As Long
Application.ScreenUpdating = False
For Each c In Range(Cell1:=Range("A2"), Cell2:=Range("A2").End(xlDown))
p = InStr(c.Value, "MM")
If p > 0 Then
c.Characters(Start:=p + 2, Length:=1000).Font.Bold = True
End If
Next c
Application.ScreenUpdating = True
End Sub
With the insertion point anywhere in the code, press F5 to execute it.
Switch back to Excel.
If you want to be able to run the macro again later on, save the workbook as a macro-enabled workbook (*.xlsm) and make sure that you allow macros when you open it.
Aug 07 2024 03:03 PM
@HansVogelaar Thank you for the amazingly quick response. Unfortunately, we use Microsoft 365. I tried it anyway but it didn't work. Again, though....thank you
Scott
Aug 07 2024 03:52 PM
@ScottF1870 If you have any version of Microsoft 365 except for Microsoft 365 Basic, you can use the desktop version of Excel on Mac and Windows. If you do not have that yet, you can install the local apps by logging in to https://www.office.com with your Microsoft 365 account and clicking the Install link.
The macro should work - I tested it using Excel in Microsoft 365 for Windows.
Aug 07 2024 05:53 PM
online sql:
select regreplace('(?<=MM).*','<b>\0</b>',f01),* from Sheet2;
https://e.anyoupin.cn/EData/?s=1321