编写VBA宏生成页面

概述

依据详细设计中表设计,借用excel宏编写VBA生成页面。

特色

高定制、高效率、兼容所有生成要求、不依赖低耦合、任意Sheet适用

缺陷

不支持批量Sheet页生成

VBA源码

Sub listPage()
'
' 沫沫金
' 生成居民健康档案列表页面,时间: 2017/08/17
'
Dim tri As Integer, th, td As String
'生成表格头
th = "<tr>"
td = "<tr>"
For n = 7 To [D65536].End(xlUp).Row
    '字段说明
    th = th + "<th scope=""col"">" + Cells(n, "D") + "</th>"
    '字典值特殊处理
    If Cells(n, "O") = "" Then
    td = td + "<td>${phealth." + Cells(n, "I") + "}</td>"
    Else
    td = td + "<td><dic:dic type=""" + Cells(n, "O") + """ value=""${phealth." + Cells(n, "I") + "}"" /></td>"
    End If
Next n
'拼接一行,扔到空闲列统一拷贝
Cells(7, "B") = th + "</tr>"
Cells(8, "B") = td + "</tr>"
'跳转到指定Sheet
Sheets(2).Activate
MsgBox "恭喜你,列表内容生成成功。"
'
End Sub

以上,谢谢。有修复缺陷的同仁,可添加微信指导

by.沫沫金

于2017-08-17 西安

祝所有项目人员战斗满满、收获满满、人气满满。
原文地址:https://www.cnblogs.com/zl0828/p/7382349.html