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
相关推荐
KeThink9 分钟前
国民经济行业分类 GB/T 4754—2017 (PDF和exce版本)
pdf·excel
_oP_i28 分钟前
Excel 的多线程特性
excel
V1ncent Chen4 小时前
Excel基础:数据查看
excel
谁他个天昏地暗13 小时前
Java 实现 Excel 文件对比与数据填充
java·开发语言·excel
梦想blog14 小时前
Spring Boot + Easy Excel 自定义复杂样式导入导出
excel
UrbanJazzerati1 天前
使用Excel制作多类别占比分析字母饼图
excel
The Future is mine1 天前
Python实现文件夹中文件名与Excel中存在的文件名进行对比,并进行删除操作
excel
Tomorrow'sThinker2 天前
[特殊字符] Excel 读取收件人 + Outlook 批量发送带附件邮件 —— Python 自动化实战
python·excel·outlook
盛夏绽放2 天前
ExcelJS 完全指南:专业级Excel导出解决方案
excel·有问必答
bing_1582 天前
Excel 如何进行多条件查找或求和?
excel