[英]Excel VBA inserting row
I have a little problem with my macro. 我的宏有点问题。 I just want to insert a dynamic number of rows, above a specific row which should copy everything from that specific row.
我只想在特定行上方插入动态行数,该行应复制该特定行中的所有内容。 So formatting, formulas, text, merged cells basically everything.
因此,格式,公式,文本,合并的单元格基本上都是一切。
Now my code actually inserts the number of rows I need and it does copy the formatting. 现在,我的代码实际上插入了我需要的行数,并且确实复制了格式。 The stuff I am missing is the text/formulas in the cells and the cells are not merged at all(like in the row below).
我所缺少的是单元格中的文本/公式,并且这些单元格根本没有合并(如下面的行中所示)。
what I have so far is this: 我到目前为止所拥有的是:
Set ins = wsCopyTo.Range("A100")
Do While k > 0 = True
ins.EntireRow.Insert
k = k - 1
Loop
now for easy reasons lets just assume k is 100 since as I said the number of rows which I insert is actually correct. 现在出于简单的原因,我们只假设k为100,因为正如我所说,我插入的行数实际上是正确的。
This works: 这有效:
Sub copyXrows()
Dim ins As Range
Dim k As Integer
Set ins = Tabelle1.Range("A10")
ins.Select
k = 2
Do While k > 0 = True
ins.EntireRow.Copy
ins.EntireRow.Insert
k = k - 1
Loop
End Sub
You miss a entirerow.copy command. 您错过了一个wholerow.copy命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.