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
相关推荐
Non-existent98715 分钟前
Excel/CSV转GIS:一键WKT转gdf、Shapefile等图层
信息可视化·excel
dyxal39 分钟前
Excel情感标注工具:用Python+Flask打造高效数据标注平台
python·flask·excel
开开心心就好1 小时前
音频格式互转工具,支持Mp3ApeWavFlac互转
java·网络·c++·windows·qt·电脑·excel
夜流冰15 小时前
Excel - MS Support for Excel: 2 Collaborate
数据库·windows·excel
LingRannn1 天前
【vim 中如何替换】
编辑器·vim·excel
yesyesido1 天前
智能文件格式转换器:文本/Excel与CSV无缝互转的在线工具
开发语言·python·excel
开开心心_Every2 天前
免费进销存管理软件:云端本地双部署
java·游戏·微信·eclipse·pdf·excel·语音识别
Kasen's experience2 天前
Excel 怎么快速合并同一个ID不同行的大量相同单元格
excel
mudtools2 天前
基于.NET操作Excel COM组件生成数据透视报表
c#·.net·excel
yangminlei2 天前
Spring Boot+EasyExcel 实战:大数据量 Excel 导出(高效无 OOM)
spring boot·后端·excel