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
相关推荐
2501_9307077837 分钟前
使用C#代码在 Excel 中添加或设置批注格式
excel
梦因you而美4 小时前
Python win32com 复制Excel sheet优化:覆盖替换而非删除重建,彻底解决公式报错
python·excel·win32com·python自动化·批量复制sheet表
asdzx675 小时前
使用 C# 将 Excel 转换成高质量 JPG
开发语言·c#·excel
城数派5 小时前
2014-2025年全国监测站点的逐月空气质量数据(15个指标\Excel\Shp格式)
arcgis·信息可视化·数据分析·excel
Metaphor6921 天前
使用 Python 操作 Excel 文件中的工作表(添加和删除)
python·excel
开开心心就好1 天前
支持自定义名单的实用随机抽签工具
windows·计算机视觉·计算机外设·excel·散列表·启发式算法·csdn开发云
李昊哲小课1 天前
Python办公自动化教程 - 第2章 单元格样式魔法 - 让表格变得美观专业
开发语言·python·excel·openpyxl
孙同学20201 天前
如何将 JSON 数据转换为 Excel 工作表
python·json·excel
奔跑的呱呱牛2 天前
前端/Node.js操作Excel实战:使用@giszhc/xlsx(导入+导出全流程)
前端·node.js·excel·xlsx·sheetjs
Metaphor6922 天前
使用 Python 设置 Excel 表格的行高与列宽
开发语言·python·excel