博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VBA-从周课表统计节次
阅读量:6902 次
发布时间:2019-06-27

本文共 1438 字,大约阅读时间需要 4 分钟。

Sub datainsert()    Dim r1 As Integer, r2 As Integer, i As Integer, j As Integer, findrow As Integer, findMonth As Integer, tday As Integer        findMonth = Range("h1")    Set Source = Worksheets("总周课表")        Set t = ActiveSheet        r1 = Source.Range("a65536").End(xlUp).Row        '开始循环        For i = 2 To r1                xm = Source.Cells(i, 8)        kc = Source.Cells(i, 7)        jc = Source.Cells(i, 6)        rq = Source.Cells(i, 4)        bc = Source.Cells(i, 3)        dd = Source.Cells(i, 9)            '比较日期        If Format(rq, "M") = findMonth Then                r2 = t.Range("c65536").End(xlUp).Row        If (r2 < 3) Then r2 = 3                tday = Format(rq, "d") + 7 '后移7个单元格                    findrow = 0                    For j = 3 To r2                                If t.Cells(j, 3) = xm Then                    findrow = j                    Exit For                End If                        Next                        If (findrow > 0) Then '找到                        t.Cells(findrow, tday) = Cells(findrow, tday) & " " & jc                                    Else '没找到直接添加                          t.Cells(r2 + 1, 3) = xm                t.Cells(r2 + 1, 4) = kc                t.Cells(r2 + 1, 6) = bc                t.Cells(r2 + 1, 39) = dd                t.Cells(r2 + 1, tday) = jc                        End If           End If    NextEnd Sub

 

转载于:https://www.cnblogs.com/lunawzh/p/7506934.html

你可能感兴趣的文章
IT兄弟连 JavaWeb教程 jQuery对AJAX的支持
查看>>
Windows SqlServer 2008服务1433端口不监听问题排查
查看>>
oracle 11g rac安装之oracle database报错解决
查看>>
linux固定用户访问ip限制
查看>>
华为SSH配置
查看>>
比较好用的dns列表
查看>>
linux下mysql的root密码忘记解决方法
查看>>
多机调度问题-贪心算法
查看>>
sql_trace的使用
查看>>
我的友情链接
查看>>
WordPress 禁用自动保存、文章多个版本
查看>>
JDK环境配置
查看>>
修改Linux中的root密码
查看>>
搭建本地yum仓库
查看>>
CentOS7 源码编译安装稳定LNMP环境 支持Zabbix
查看>>
常用软件包下载网址
查看>>
Vagrant中Apache或Nginx,修改css/js等静态文件不生效的解决方案
查看>>
Arduino学习笔记01——单个LED灯闪烁
查看>>
学习linux计划书
查看>>
我的友情链接
查看>>