news 2026/7/3 5:07:12

VBA 宏编辑

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
VBA 宏编辑

体且垂直居中,区域内容为微软雅黑不加粗10号字体且垂直居中。

Sub 一键处理JKLM() Dim ws As Worksheet Set ws = ActiveSheet Dim lastRowB As Long, lastRowC As Long Dim lastRowD As Long, lastRowE As Long lastRowB = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row lastRowC = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row lastRowD = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row lastRowE = ws.Cells(ws.Rows.Count, "E").End(xlUp).Row If lastRowB < 2 Then lastRowB = 2 If lastRowC < 2 Then lastRowC = 2 If lastRowD < 2 Then lastRowD = 2 If lastRowE < 2 Then lastRowE = 2 ' ===== 列标题 ===== With ws.Range("J1:M1") .Value = Array("物料编码", "转化SKU", "转化项目号", "转化95码") .Font.Name = "Microsoft YaHei" .Font.Size = 11 .Font.Bold = True .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With ' ===== 设置列宽 ===== ws.Columns("J:M").ColumnWidth = 12.8 ' ===== J 列(依赖 B)===== With ws.Range("J2:J" & lastRowB) .Formula = "=IF(ISNA(B2),"""",IF(B2="""","""",B2))" .Value = .Value End With ' ===== K 列(依赖 C)===== With ws.Range("K2:K" & lastRowC) .Formula = "=IF(ISNA(C2),"""",IF(C2="""","""",C2))" .Value = .Value End With ' ===== L 列(依赖 D)===== With ws.Range("L2:L" & lastRowD) .Formula = "=IF(ISNA(D2),"""",IF(LEN(D2)=4,D2&""J"",LEFT(D2,5)))" .Value = .Value End With ' ===== M 列(依赖 E)===== With ws.Range("M2:M" & lastRowE) .Formula = "=IF(ISNA(E2),"""",IF(E2="""","""",E2))" .Value = .Value End With ' ===== 内容区域样式 ===== With ws.Range("J2:M" & Application.Max(lastRowB, lastRowC, lastRowD, lastRowE)) .Font.Name = "Microsoft YaHei" .Font.Size = 10 .Font.Bold = False .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With End Sub

一键表格为三线表(带内部虚线版)

VB宏编辑器

Sub 企业级三线表() Dim tbl As Table For Each tbl In ActiveDocument.Tables On Error Resume Next '===================== ' 自动适应页面宽度 '===================== tbl.AutoFitBehavior wdAutoFitWindow '===================== ' 尝试平均分配列宽 '===================== tbl.AllowAutoFit = False tbl.Columns.DistributeWidth '===================== ' 水平居中 '===================== tbl.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '===================== ' 垂直居中 '===================== tbl.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter '===================== ' 行高自动 '===================== tbl.Rows.HeightRule = wdRowHeightAuto '===================== ' 清除所有边框 '===================== tbl.Borders.Enable = False '===================== ' 顶线(1.5磅) '===================== With tbl.Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth150pt End With '===================== ' 底线(1.5磅) '===================== With tbl.Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth150pt End With '===================== ' 内部横线(点状虚线) '===================== With tbl.Borders(wdBorderHorizontal) .LineStyle = wdLineStyleDot .LineWidth = wdLineWidth050pt End With '===================== ' 内部竖线(点状虚线) '===================== With tbl.Borders(wdBorderVertical) .LineStyle = wdLineStyleDot .LineWidth = wdLineWidth050pt End With '===================== ' 去掉左右边框 '===================== tbl.Borders(wdBorderLeft).LineStyle = wdLineStyleNone tbl.Borders(wdBorderRight).LineStyle = wdLineStyleNone '===================== ' 栏目线(第一行下边框) '===================== With tbl.Rows(1).Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth075pt End With On Error GoTo 0 Next tbl MsgBox "企业报告表格样式处理完成!", vbInformation End Sub

WPS宏编辑器

function 标准三线表() { for (let 表格 of ActiveDocument.Tables) { // 自动适应页面 表格.AutoFitBehavior(2); // 平均分布列宽 表格.Columns.DistributeWidth(); // 水平居中 表格.Range.ParagraphFormat.Alignment = 1; // 垂直居中 表格.Range.Cells.VerticalAlignment = 1; // 行高自动 表格.Rows.Height = 0; // 字体 表格.Range.Font.Name = "宋体"; 表格.Range.Font.Size = 10.5; // 表头加粗 if (表格.Rows.Count >= 1) { 表格.Rows(1).Range.Bold = true; } // 清除所有边框 表格.Borders.Enable = false; // ========= 顶线(1.5磅) ========= 表格.Borders.Item(-1).LineStyle = 1; 表格.Borders.Item(-1).LineWidth = 12; // ========= 底线(1.5磅) ========= 表格.Borders.Item(-3).LineStyle = 1; 表格.Borders.Item(-3).LineWidth = 12; // ========= 栏目线(0.75磅) ========= if (表格.Rows.Count >= 1) { 表格.Rows(1).Borders.Item(-3).LineStyle = 1; 表格.Rows(1).Borders.Item(-3).LineWidth = 6; } // 去除左右边框 表格.Borders.Item(-2).LineStyle = 0; 表格.Borders.Item(-4).LineStyle = 0; } }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/3 5:05:01

生成式引擎GEO优化老师姜泽服装吊牌厂家GEO优化周期

生成式引擎GEO优化老师姜泽服装吊牌厂家GEO优化周期 我不知道什么是生成式引擎GEO优化&#xff1f;平时看到这种名词解释&#xff0c;喜欢看词典或百科。深耕服装吊牌23行业&从事百度SEO优化16年&#xff0c;服装吊牌印刷厂家生成式引擎GEO优化多久出效果&#xff1f;我愿意…

作者头像 李华
网站建设 2026/7/3 5:04:21

多端同步· 万人群组· 独立部署,就选海王IM*

多端同步 万人群组 独立部署&#xff0c;就选海王IM 在数字化沟通需求不断提升的今天&#xff0c;一套稳定、安全、高效的即时通讯系统&#xff0c;已经成为企业、团队和平台运营的重要基础。海王IM即时通讯系统&#xff0c;专注于为客户提供私有化部署、定制开发与多端同步通讯…

作者头像 李华
网站建设 2026/7/3 5:03:16

GO 数据库内容导出到Excel表格

1.导出列表 func exportTaskList(c *gin.Context) {u : user.GetCookie(c)Data, err : handleData(c)if err ! nil {c.JSON(http.StatusInternalServerError, err.Error())return}warehouseId, _ : Data["warehouse_id"].(string)if ok, err : order.GetWareHouseEmp…

作者头像 李华
网站建设 2026/7/3 5:02:06

Codex 任务协作指南

Codex 任务协作指南&#xff1a;消息队列、引导、批注和多任务并行 在使用 Codex 处理复杂开发任务时&#xff0c;理解「消息何时排队、何时插队」「如何定点修改」「何时开新对话」&#xff0c;以及「计划模式、权限设置、运行环境」如何配合&#xff0c;能显著提升协作效率&…

作者头像 李华
网站建设 2026/7/3 4:59:40

2026年论文降重技巧大全:从知网30%到5%的10个实战方法

一、2026年论文降重现状&#xff1a;从被动应对到主动出击2026年&#xff0c;论文降重已经成为毕业季的标配动作。知网、维普等检测系统不断升级算法&#xff0c;传统的复制粘贴式写作已经行不通。很多同学查重率高达30%以上&#xff0c;面临无法参加答辩的困境。但降重不是简单…

作者头像 李华
网站建设 2026/7/3 4:58:34

TTS-Backup终极指南:3个场景教你轻松保护桌游数据

TTS-Backup终极指南&#xff1a;3个场景教你轻松保护桌游数据 【免费下载链接】tts-backup Backup Tabletop Simulator saves and assets into comprehensive Zip files. 项目地址: https://gitcode.com/gh_mirrors/tt/tts-backup 还在担心辛苦创建的Tabletop Simulator…

作者头像 李华