|
▼nonoka さん:
こんにちは
まだ、ざくっとした確認しかしていないのですが・・・
で、さらに手を抜いて K3 の値が万が一入れなおされても処理はしないことにしました。
Option Explicit
Const shName As String = "Sheet1" '実際のものに
Private Sub Workbook_Open()
With Sheets(shName)
Call Sample(.Range("K10", .Range("K" & .Rows.Count).End(xlUp)))
End With
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim r As Range
If Not Sh Is Sheets(shName) Then Exit Sub
Set r = Intersect(Target, Sh.Columns("K"))
If r Is Nothing Then Exit Sub
If Target.Rows(1).Cells.Count = Target.Parent.Columns.Count Then Exit Sub '行削除、挿入
Call Sample(r)
End Sub
Sub Sample(Target As Range)
Dim c As Range
Dim a As Variant
Dim r As Range
Dim bDt As Double
Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets(shName)
bDt = .Range("K3").Value2
For Each c In Target.Cells
If c.Row >= 10 Then
With c.EntireRow
.Range("L1").ClearContents
If IsDate(c.Value) Then
Set r = .Range("N1:AA1")
a = Application.Match(bDt, r, 0)
If IsNumeric(a) Then
.Range("L1").Value = Target.Parent.Cells(9, a + 13).Value
Else
a = Application.Match(.Range("K1").Value2, r, 0)
If IsNumeric(a) Then
.Range("L1").Value = Target.Parent.Cells(9, a + 13).Value
Else
If .Range("K1").Value2 < bDt Then
.Range("L1").Value = "未投入"
Else
If .Range("M1").Value2 < bDt Then .Range("L1").Value = "完了"
End If
End If
End If
End If
End With
End If
Next
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
|
|