
excel
Sub InsertHorizontlines()Dim r As RangeFor Each r In SelectionWith r.Range.Cells(r, 1).EntireColumn.InsertSpace 1, 0, False.Cells(.LastRow, 1).EntireColumn.InsertSpace 1, 0, False.Cells(.FirstRow, 1).EntireColumn.InsertSpace 1, 0, False.SetIntersect(.EntireColumn.InsertSpace 1, 0, False)End WithNextEnd Sub这个代码会自动向所有选定的单元格之间添加粗细为1的水平线条。你可以将代码复制到Visual Basic Editor中进行运行,或者将代码插入到一个Module模块中,并在excel VBA编辑器中使用。
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号