我在excel电子表格中有以下内容以及更多内容:
service instance 404 ethernet
description Name 661-1-11-3-15
encapsulation dot1q 804 second-dot1q 4
rewrite ingress tag pop 2 symmetric
bridge-domain 804 split-horizon
service instance 405 ethernet
description Name 661-1-11-4+1
encapsulation dot1q 804 second-dot1q 5
rewrite ingress tag pop 2 symmetric
bridge-domain 813 split-horizon
service instance 408 ethernet
description Name 661-1-12-1-4
encapsulation dot1q 804 second-dot1q 8
rewrite ingress tag pop 2 symmetric
bridge-domain 823 split-horizon
我需要让它看起来如下:
service instance 404 ethernet
description Name 661-1-11-3-15
encapsulation dot1q 804 second-dot1q 4
rewrite ingress tag pop 2 symmetric
bridge-domain 804 split-horizon
service-policy input platinum-up
service-policy output platinum-dn
service instance 405 ethernet
description Name 661-1-11-4+1
encapsulation dot1q 804 second-dot1q 5
rewrite ingress tag pop 2 symmetric
bridge-domain 813 split-horizon
service-policy input platinum-up
service-policy output platinum-dn
service instance 408 ethernet
description Name 661-1-12-1-4
encapsulation dot1q 804 second-dot1q 8
rewrite ingress tag pop 2 symmetric
bridge-domain 823 split-horizon
service-policy input platinum-up
service-policy output platinum-dn
基本上会为每个空白插入两行数据('服务政策输入白金''服务政策输出白金-dn')和空白行每个数据集之间的行。除了插入2个空白行并将数据复制到空白处之外,有人能告诉我一种更简单的数据插入方法吗?
谢谢, J. R。
答案 0 :(得分:0)
非常简单。
Sub InsertLines()
Dim Row As Long
ActiveSheet.UsedRange
Row = 6
Do
Range(Cells(Row, 1), Cells(Row + 1, 1)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(Row, 1).Value = " service-policy input platinum-up"
Cells(Row + 1, 1).Value = " service-policy output platinum-dn"
Row = Row + 8
Loop Until Row > ActiveSheet.Cells.SpecialCells(xlLastCell).Row + 1
End Sub