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
相关推荐
开开心心就好1 天前
系统重装前必备的智能驱动备份工具
windows·计算机视觉·计算机外设·excel·模块测试·csdn开发云·威胁分析
向宇it2 天前
php高性能的导出excel读写扩展——xlswriter,比传统的Spreadsheet要快很多
php·excel·xlswriter
yanweijie03172 天前
对比VLOOKUP、XLOOKUP、INDEX+MATCH三大查找函数
excel
Codiggerworld2 天前
Vim的语法:删除、复制、粘贴,像说话一样自然
编辑器·vim·excel
Pentane.2 天前
【数据分析 | 农业项目】蔬菜类商品的自动定价与补货决策 | Tableau & Excel
数据挖掘·数据分析·excel·tableau
happy_baymax2 天前
Simulink 端口自动生成工具 (v2.1)(EXCEL+m语言)
服务器·matlab·excel·simulink
SunnyDays10112 天前
如何使用 C# 高效实现 Excel 与 CSV 的互相转换
c#·excel·csv
热爱生活的五柒2 天前
excel的使用教程
excel
城数派2 天前
2025年我国省市县三级的平均坡度数据(Excel\Shp格式)
arcgis·信息可视化·数据分析·excel
大佬,救命!!!3 天前
etp中未运行用例顺序的定位及补齐脚本自动化生成
python·学习笔记·excel·自动化脚本·用例整理清洗