スプレッドシートの選択領域に条件付き書式を設定するExcel 2010 VBAマクロがあります。例として次のコードを検索し、その後色セルテキストパターンを:条件付き書式設定のRegExを使用するExcel VBA
Selection.FormatConditions.Add Type:=xlTextString, String:="TextToMatch", _
TextOperator:=xlContains Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ColorIndex = 36
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
私が追加したいと思いますどのような正規表現TN[0-9]
照合することです。文字列TN
の後に数字が続く単純な一致。
Dim regEx As Object
Set regEx = CreateObject("VBScript.RegExp")
With regEx
.Pattern = "TN[0-9]"
End With
私はSelection
にこれを適用する方法を考え出したていないが:
私は、RegExp obectを作成しました。
いつもよろしくお願いします。
マクロ内これをやっている場合は、選択中のセルを反復し、正規表現マッチ_if_各セルのためにあなたのFormatConditionsを設定することができますか? –
なぜ正規表現ですか?あなたは 'Cell.Value Like" TN# "'で同じことを達成できます –