本文主要是介绍VBA Excel 出报表,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
源数据
目标
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 Variantps = Range("I1").Value
pe = Range("I2").Value
srcs = Range("C1").Value
srce = Range("C2").ValueFor i = ps To peFor j = 2 To 32For m = srcs To srcepname = Sheets("Sheet3").Range("A" & m).ValueIf pname = Range("A" & i).Value Thenpndme = Cells(6, j).ValueIf Sheets("Sheet3").Range("B" & m).Value <= pndme And Sheets("Sheet3").Range("C" & m).Value >= pndme ThenCells(i, j).Value = Sheets("Sheet3").Range("D" & m).ValueIf Cells(i, j).Value = "调休" ThenCells(i, j).Interior.ColorIndex = 6End IfEnd IfEnd IfNextNext
NextEnd Sub
这篇关于VBA Excel 出报表的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!