そこで、EXCELで「選択」しているセル(複数かつ、点在していてもOK)について、
+5百万であれば、青字で+5百万円、−5百万円ならば、赤字で−5百万円と表示するVBAマクロは、以下のような感じ。
![]() |
excergirl |
ポイントとしては、「選択」しているセルを取り出すFor Each r In Selectionと「+n百万円」を正規表現RegExpで見つけているところ。
- Sub minusakaandplusaoHK()
- Dim strPat As String
- Dim strTest As String
- ' -digits red
- For Each r In Selection
- strTest =r.Value
- Set RE =CreateObject("VBScript:RegExp")
- Set Matches = RE.Execute (strTest)
- strPat = "(¥-|−)([0-9]|[0−9])+(.|.)? ([0-9]|[0−9]) *百万円" --- pattern for search
- With RE
- .Pattern = StrPat
- .IgnoreCase =False
- .Global = True
- End With
- Set Matches = RE.Exceutes(strTest)
- If Matches.Count <> 0 then
- For Each Match In Matches
- r.Characters(Start:=Match.FirstIndex + 1,Length:=Match.Length).Font.ColorINdex = 3
- Next
- Endif
- Next r
- '+digits blue
- For Each r In Selection
- strTest =r.Value
- Set RE =CreateObject("VBScript:RegExp")
- Set Matches = RE.Execute (strTest)
- strPat = "(¥+|+)[0-9]|[0−9])+(.|.)? ([0-9]|[0−9]) *百万円" --- pattern for search
- With RE
- .Pattern = StrPat
- .IgnoreCase =False
- .Global = True
- End With
- Set Matches = RE.Exceutes(strTest)
- If Matches.Count <> 0 then
- For Each Match In Matches
- r.Characters(Start:=Match.FirstIndex + 1,Length:=Match.Length).Font.ColorINdex = 5
- Next
- Endif
- Next r
- End Sub
ちょっと一息のコーナー。
トマス ・H・クックの「鹿の死んだ夜」(染田屋茂 訳、文春文庫)は、月曜日に「自宅の窓ごしに眺めると、リアダンには街が、でたらめな音と方向性のない動きの巨大なパッチワークに見えた。」という描写で静かに始まる。
もう、随分前にこの本と出会い、思い浮かべるたびにその哀しい余韻が印象に残っている。原書のタイトルは、ブラッド・イノセント(blood innocent)。何年も絶版になった原書を探していたところ、電子書籍の時代となり、kindle本を購入することができた。
原書では、MONDAY Watching it from his window, Reardon saw the city only as an immense patchwork of random sound and direction-less movement. で始まる。
immenseは、巨大ななんだー。kindle本は単語の意味がでるので、便利ですね。
タイトルが「ブラッド・イノセント」ではなく、「鹿の死んだ夜」になっていることのも「いいね」ですが、原書を読み返すたびに、染田屋訳の凄さ、絶妙さを感じています。トマス・クックもこれが処女作というのも凄い。
0 件のコメント:
コメントを投稿