无法保留range.insert上的边框格式

Laz*_*eye 5 excel vba excel-vba

有没有办法在保留边框格式的同时插入新行?我能够插入,同时保留除边框之外的所有格式.我创建的宏实际上将提示用户输入值(strXX),然后在列表中搜索它.如果不存在,则执行以下操作.

iRow = WorksheetFunction.Match(strXX, Columns("A")) + 1
Intersect(Range("Z:TT"), Rows(iRow)).Insert _
XlInsertShiftDirection.xlShiftDown, CopyOrigin:=Excel.XlInsertFormatOrigin.xlFormatFromLeftOrAbove
Run Code Online (Sandbox Code Playgroud)

对于CopyOrigin,我有什么必须改变的吗?似乎有通过粘贴功能可用的方法,但是在使用.Insert时我无法找到类似的方法.

非常感谢任何帮助...谢谢!

更新(8/15): 自从这篇文章以来,我在电子表格中重新格式化了一些内容,并且能够解决这个问题.我仍然对反馈非常感兴趣,因为原始配置无法复制边框.这肯定会在以后重新出现.请参阅下面的支持信息.

有2张将更新.第1个工作正常,因为它保留了单元格格式(不需要边框).见下文. 在此输入图像描述

此帖子中描述的问题与第二张相关.插入行并保留除边框以外的所有格式(标准"外部边框"设置).见下文. 在此输入图像描述

And*_*ewT 1

只需按照评论中建议的代码执行即可,如下所示

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
Run Code Online (Sandbox Code Playgroud)