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
相关推荐
2601_9679801113 小时前
Python自动化办公:模块、库与样式调整教程
python·excel·自动化办公·openpyxl·样式调整
用户03321266636716 小时前
使用 Python 轻松加密或解密 Excel 文档
python·excel
总裁余(余登武)2 天前
【python项目】:1操作EXCEl自动化开发
python·自动化·excel
ailitsoft4 天前
库存管理系统如何记录跨门店调拨后的收货差异?
excel·零售·软件需求
百事牛科技5 天前
Excel的三种密码:防看、防存、防乱改,各管各的
windows·excel
用户298698530146 天前
React 前端将 Excel 工作表导出为图片的技术实践
javascript·react.js·excel
用户0332126663677 天前
使用 Python 在 Excel 文档中添加水印
python·excel
科技新资讯8 天前
AI如何批量处理Excel文件? 从数据合并、清洗到自动生成报表,看看 AI Agent 怎么完成任务
大数据·人工智能·excel
用户0332126663678 天前
使用 Python 在 Excel 中添加与删除筛选器
python·excel
xurime9 天前
Excelize 开源基础库发布 2.11.1 版本更新
数据分析·excel·开源软件·excelize·gitcode