Excel宏编程相关封装模块-第3期
1. 说明
该模块是根据Excel宏编程官网及录制时相关操作进行编写的,如有不足之处,望批评指正!!!
2. 代码
2.1 调整区域内字体和大小
选中一定的区域,调整区域内字体和大小
Function AssistTypeSize(H1, L1, H2, L2, Typeface, Size)
'对于选中的区域修改字体和大小及居中处理 _ ,,首位_,,末位_字体_大小
Range(Cells(H1, L1), Cells(H2, L2)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Name = Typeface
.Size = Size
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
End With
End Function
输入内容
AssistTypeSize(H1, L1, H2, L2, “宋体”, 20)
效果如下
2.2 内容填充
按需要向右输入更改内容(逐个输入)
Function AssistAlterRowName(H, l, Name1, Name2, Name3, Name4, Name5)
'按需要向右输入更改内容 _ ,,首位_yi_er_san_si_wu
Cells(H, l).Value = Name1
Cells(H, l + 1).Value = Name2
Cells(H, l + 2).Value = Name3
Cells(H, l + 3).Value = Name4
Cells(H, l + 4).Value = Name5
End Function
从某位置开始向右更改输入内容(列表输入)
Function AssistAlterRow(H, l, WB_Endto, Start, Need)
'从某位置开始向右更改输入内容 _ 某行_首位_内容_起始位_截止位
For i = Start To Need
Cells(H, l + i - Start).Select
ActiveCell.FormulaR1C1 = WB_Endto(i)
Next
End Function
从某位置开始向下更改输入内容(列表输入)
Function AssistAlterColumn(H, l, WB_Endto, Start, Need)
'从某位置开始向下更改输入内容 _ 某行_首位_内容_起始位_截止位
For i = Start To Need
Cells(H + i - Start, l).Select
ActiveCell.FormulaR1C1 = WB_Endto(i)
Next
End Function
参考地址:https://docs.microsoft.com/zh-cn/office/client-developer/excel/excel-home?redirectedfrom=MSDN
该代码仅供学习,如商业转载请联系本人,非商业转载请注明出处