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
相关推荐
开开心心_Every15 小时前
进程启动瞬间暂停工具,适合调试多开
运维·服务器·gitee·pdf·开源·电脑·excel
葡萄城技术团队15 小时前
表格工具栏:像 Excel 只是起点,按需定制才是关键
excel
开开心心就好16 小时前
直接减少蓝光辐射的专业护眼工具
linux·运维·服务器·智能手机·excel·java-rabbitmq·sdkman
得闲喝茶2 天前
SQL处理数据的常用语法语句
数据库·笔记·sql·数据分析·excel
hmywillstronger2 天前
【Python】从SAP2000 XML截面库提取数据到Excel
xml·python·excel
抹茶咖啡2 天前
IT运维的365天--045 WPS突然就不能正常打开Excel文件了
excel·it运维·wps
专注VB编程开发20年2 天前
在 Python 中使用 comtypes 时,大小写通常必须保持精确
python·excel
E_ICEBLUE3 天前
如何提取 Word 文档中的表格并导出为 Excel(Python 教程)
python·word·excel
2501_930707783 天前
使用C#代码在 Excel 中创建雷达图
信息可视化·excel