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 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
相关推荐
一晌小贪欢5 小时前
【Html模板】电商运营可视化大屏模板 Excel存储 + 一键导出(已上线-可预览)
前端·数据分析·html·excel·数据看板·电商大屏·大屏看板
oh,huoyuyan9 小时前
【实战案例】火语言 RPA 采集豆瓣电影剧名、评分等(加载更多),保存到 Excel 全流程(附完整脚本)
excel·rpa
AntHub11 小时前
vba 输出到日志文件
excel
zhangyao9403301 天前
关于js导入Excel时,Excel的(年/月/日)日期是五位数字的问题。以及对Excel日期存在的错误的分析和处理。
开发语言·javascript·excel
X@AKS2 天前
解决使用EasyExcel导出带公式的excel,公式不自动计算问题
excel
Wang201220132 天前
wps excel中把特定几列除以某一列,然后以百分比显示
excel
LilySesy2 天前
ABAP+在select的时候,可以A=B A=C B=C这样子JOIN吗?
数据库·sql·ai·excel·sap·abap
zhishidi2 天前
Excel表格自适应大小设置方法
excel
缺点内向2 天前
C#: 高效移动与删除Excel工作表
开发语言·c#·.net·excel
程序员晚枫3 天前
Python处理Excel的5个“神仙库”,办公效率直接翻倍!
python·excel