源数据
目标
PS:调休 以高亮颜色区分
整理一下
CMDBUT命令 VBA代码
Private Sub CommandButton1_Click()
Dim ps As Integer
Dim pe As Integer
Dim srcs As Integer
Dim srce As Integer
Dim i As Integer
Dim j As Integer
Dim m As Integer
Dim pname As Variant
Dim pndme As Variant
ps = Range("I1").Value
pe = Range("I2").Value
srcs = Range("C1").Value
srce = Range("C2").Value
For i = ps To pe
For j = 2 To 32
For m = srcs To srce
pname = Sheets("Sheet3").Range("A" & m).Value
If pname = Range("A" & i).Value Then
pndme = Cells(6, j).Value
If Sheets("Sheet3").Range("B" & m).Value <= pndme And Sheets("Sheet3").Range("C" & m).Value >= pndme Then
Cells(i, j).Value = Sheets("Sheet3").Range("D" & m).Value
If Cells(i, j).Value = "调休" Then
Cells(i, j).Interior.ColorIndex = 6
End If
End If
End If
Next
Next
Next
End Sub