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
相关推荐
拷斤锟37 分钟前
使用Excel解析从OData API获取到的JSON数据
数据库·json·excel
野生程序员y40 分钟前
day21-Excel文件解析
excel
WSSWWWSSW4 小时前
vi/vim跳转到指定行命令
编辑器·vim·excel
前端sweetGirl13 小时前
EXCEL批量生成超链接引用无效的情况
excel
肖恩部落20 小时前
Excel: xls与xlsx格式转换排坑指南
excel·xlsx·xls
chenchihwen2 天前
大模型应用班-第3课 从Excel到大屏:AI编程实战全解析 HW3 从零到一:香港疫情数据看板开发实战指南
excel·ai编程
33255_40857_280592 天前
使用EasyPOI实现Java订单数据导出(含多物料信息)——模板语法详解与实战
java·excel
我今晚不熬夜2 天前
Excel文件解析
excel
开开心心就好2 天前
PDF转图片工具,一键转换高清无损
服务器·前端·智能手机·r语言·pdf·excel·batch
CodeCraft Studio3 天前
国产化Excel处理组件Spire.XLS教程:使用 Java 将 CSV 转换为 Excel
java·python·excel