Excelで、特定の単語をセル内で検索し、その特定の単語のみを置換する必要があります。では、セル内の特定の文字列を検索し、その特定の文字列にスタイルを適用する必要があります。
例えば:Excelの はセルが含まれていてもよい
「チームファイルにテストデータをロードしているはず」
私のようなこの行で唯一の単一の単語を選択しますテストとその特定の文字列にスタイルを適用
「チームはファイルにテストデータをロードしている必要があります」
私はので、私はここではVBA
Excelで、特定の単語をセル内で検索し、その特定の単語のみを置換する必要があります。では、セル内の特定の文字列を検索し、その特定の文字列にスタイルを適用する必要があります。
例えば:Excelの はセルが含まれていてもよい
「チームファイルにテストデータをロードしているはず」
私のようなこの行で唯一の単一の単語を選択しますテストとその特定の文字列にスタイルを適用
「チームはファイルにテストデータをロードしている必要があります」
私はので、私はここではVBA
何かが太字にユーザが選択した範囲内の全てのセルに「テスト」に変更します。これは、テストがありますどのように多くの細胞?あなたは、細胞内の特定の単語を選択し、書式設定を適用することにより、手動でそれを行うことができない多くの場合は大文字と小文字を区別しません
Option Explicit
Const strText As String = "test"
Sub ColSearch_DelRows()
Dim rng1 As Range
Dim rng2 As Range
Dim cel1 As Range
Dim cel2 As Range
Dim strFirstAddress As String
Dim lAppCalc As Long
Dim objRegex As Object
Dim RegMC As Object
Dim RegM As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Global = True
.Pattern = strText
End With
'Get working range from user
On Error Resume Next
Set rng1 = Application.InputBox("Please select range to search for " & strText, "User range selection", Selection.Address(0, 0), , , , , 8)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
With Application
lAppCalc = .Calculation
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Set cel1 = rng1.Find(strText, , xlValues, xlPart, xlByRows, , False)
If Not cel1 Is Nothing Then
Set rng2 = cel1
strFirstAddress = cel1.Address
Do
Set cel1 = rng1.FindNext(cel1)
Set rng2 = Union(rng2, cel1)
Loop While strFirstAddress <> cel1.Address
End If
If Not rng2 Is Nothing Then
For Each cel2 In rng2
Set RegMC = objRegex.Execute(cel2.Value)
For Each RegM In RegMC
cel2.Characters(RegM.firstindex, RegM.Length + 1).Font.Bold = True
Next
Next
End If
With Application
.ScreenUpdating = True
.Calculation = lAppCalc
End With
End Sub
を使用したいフォーマットするための多くの細胞を持っているが、セル内のテキストの一部をフォーマットする方法をお見せするためのスニペットです:
Sub EditFont()
'To format font color for 12 digits to 4 black, 5 red, 3 black:
' Here is some sample text to try it on: 123456789012
'First, format digits to be treated as characters
ActiveCell.Value = "'" & ActiveCell.Value
'Format all characters for black
With ActiveCell
.Font.ColorIndex = 3
'Format characters 5 thru 12 as red
.Characters(1, ActiveCell.Characters.Count - 8).Font.ColorIndex = 1
'Reformat characters 10 thru 12 back to black
.Characters(10, ActiveCell.Characters.Count - 3).Font.ColorIndex = 1
End With
End Sub
必要になります必要なセルにループを追加するだけで済みます。
[Sourceこのような
である単一セル内の複数の出現に
を処理します。多くの細胞の場合は、vbaを使用する必要があります。 – assylias
多くの細胞がそこにあります...また、多くの優れたもののためにこれを行う必要があります..... – user1271146
vbaで、それを行う方法.... – user1271146