有没有办法在保留边框格式的同时插入新行?我可以在插入时保留除边框之外的所有格式。我正在创建的宏本质上会提示用户输入一个值(strXX),然后在列表中搜索它。如果不存在,则执行以下内容。
iRow = WorksheetFunction.Match(strXX, Columns("A")) + 1
Intersect(Range("Z:TT"), Rows(iRow)).Insert _
XlInsertShiftDirection.xlShiftDown, CopyOrigin:=Excel.XlInsertFormatOrigin.xlFormatFromLeftOrAbove
关于CopyOrigin,有什么我必须更改的吗?似乎有通过粘贴功能可用的方法,但是在使用 .Insert 时我无法找到类似的方法。
非常感谢任何帮助...谢谢!
更新 (8/15): 自从这篇文章发布以来,我重新格式化了电子表格中的内容,并且能够解决该问题。我仍然对反馈非常感兴趣,因为原始配置无法复制边框。这肯定会在以后重新出现。请参阅下面的支持信息。
有 2 张表格需要更新。第一个效果很好,因为它保留了单元格格式(不需要边框)。见下文。
此帖子中描述的问题与第二张纸有关。该行将被插入,并且除边框(标准“外边框”设置)之外的所有格式都会保留。见下文。
最佳答案
只需按照评论中建议的代码执行即可,如下所示
With cell.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With cell.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With cell.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With cell.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
关于excel - 无法保留 range.insert 上的边框格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18223761/