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
相关推荐
小钱c73 小时前
Python使用 pandas操作Excel文件并新增列数据
python·excel·pandas
Shi_haoliu5 小时前
Vue2 + Office Add-in关于用vue项目于加载项控制excel单元格内容(Demo版)
前端·javascript·vue.js·node.js·html·excel·office
njsgcs5 小时前
json转excel python pd
python·json·excel·pd
RECRUITGUY6 小时前
Excel中将毫秒时间戳转换为标准时间格式
excel
SunkingYang8 小时前
详细介绍C++中捕获异常类型的方式有哪些,分别用于哪些情形,哪些异常捕获可用于通过OLE操作excel异常
c++·excel·mfc·异常捕获·comerror
lied166363480614 小时前
List导出到Excel文件
servlet·list·excel
ZhengEnCi20 小时前
Excel 文件结构完全指南-从基础概念到 Python 读取的实用宝典
python·excel
核桃杏仁粉1 天前
excel拼接数据库
数据库·oracle·excel
cx330上的猫1 天前
价值1w的数据分析课知识点汇总-excel使用(第一篇)
数据挖掘·数据分析·excel
小薛引路1 天前
office便捷办公06:根据相似度去掉excel中的重复行
windows·python·excel