[[20140418190038]] 『Excel VBA 予定終了時間赤文字表示』(イナチャン) ページの最後に飛ぶ

[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]

 

『Excel VBA 予定終了時間赤文字表示』(イナチャン)

Excel2013 開始時間を入力 予定終了時間を赤字で表示実終了時間を入力すると黒字で表示する。
例 予定終了時間を開始時間プラス1:30と設定する

  開始時間10:00を入力する  終了時間欄に赤字で11:30と自動表示  
  実終了時間11:00を終了時間欄に入力 11:00が黒字で表示され確定する。

< 使用 Excel:Excel2013、使用 OS:Windows8 >


 回答が付かないようなので、とりあえずのサンプルです。

 Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count <> 1 Or Target.Column <> 1 Then Exit Sub

    If Columns("B:B").FormatConditions.Count = 0 Then
        Range("B1").Select
        Columns("B:B").FormatConditions.Add Type:=xlExpression, Formula1:="=SECOND(B1)=1"
        Columns("B:B").FormatConditions(1).Font.Color = -16776961
        Target.Select
    End If

    Application.EnableEvents = False
    Target.Offset(0, 1).Value = Target.Value + TimeValue("1:30:01")
    Target.Resize(1, 2).NumberFormat = "h:mm"
    Application.EnableEvents = True
 End Sub
(Mook) 2014/04/19(土) 15:20

コメント返信:

[ 一覧(最新更新順) ]


YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki. Modified by kazu.