May 06 2022 05:10 PM
Is there a way to have Excel autocorrect the formatting of a word or phrase to italics? For example I'm trying to correct CAL to CALIFORNIA in italics. In Word, it's pretty straightforward, but there doesn't seem to be a way to do it in Excel.
I'd also accept any workarounds, for example if CAL autocorrected to CALIFORNIA, and then there was a way to automatically recognize CALIFORNIA and make it CALIFORNIA.
Any help would be greatly appreciated!
May 06 2022 05:40 PM
May 06 2022 05:45 PM
May 07 2022 01:13 AM
SolutionThis doesn't exist in Excel since, unlike Word, text processing is not its primary purpose.
You might use VBA code. In the attached workbook, Sheet1 will replace some abbreviations and italicize the replacement matching the entire cell. Sheet2 will do the same for part of the cell.
You'll have to allow macros.
The code is in the worksheet modules - right-click a sheet tab and select View Code from the context menu to see and edit it.
May 08 2022 12:09 PM
May 08 2022 12:18 PM
The current code runs automatically when you enter something in a cell.
Removing Italics seems to be more suitable for a macro to be run separately. Or do you disagree?
May 08 2022 01:02 PM
May 08 2022 01:09 PM
Your new code is also a Worksheet_Change event procedure. I thought that you agreed with me that it would be better to use an ordinary macro...
May 08 2022 01:59 PM
If you want to combine them:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim arrFind
Dim arrReplace
Dim i As Long
If Target.CountLarge > 1 Then Exit Sub
' Modify and expand the arrays as needed
arrFind = Array("CAL", "ORE")
arrReplace = Array("CALIFORNIA DREAMING", "OREGON TRAIL")
Application.EnableEvents = False
On Error GoTo ExitHere
For i = 0 To UBound(arrFind)
If Target.Value = arrFind(i) Then
Target.Value = arrReplace(i)
Target.Font.Italic = True
Exit For
End If
Next i
' Modify and expand the arrays as needed
arrFind = Array("WIS", "FLO")
arrReplace = Array("WISCONSIN RAPIDS", "FLORIDA ANGELS")
Application.EnableEvents = False
On Error GoTo ExitHere
For i = 0 To UBound(arrFind)
If Target.Value = arrFind(i) Then
Target.Value = arrReplace(i)
Target.Font.Italic = False
Exit For
End If
Next i
ExitHere:
Application.EnableEvents = True
End Sub
May 07 2022 01:13 AM
SolutionThis doesn't exist in Excel since, unlike Word, text processing is not its primary purpose.
You might use VBA code. In the attached workbook, Sheet1 will replace some abbreviations and italicize the replacement matching the entire cell. Sheet2 will do the same for part of the cell.
You'll have to allow macros.
The code is in the worksheet modules - right-click a sheet tab and select View Code from the context menu to see and edit it.