vba - 如何在 Excel 中包含数据的每一行之后插入特定值?

标签 vba excel

我正在尝试使用宏在 Excel 中包含数据的每一行之后的新行中插入一个特定值。我在网上找到了下面的脚本,但是这个脚本只插入了一个空白行。我需要插入一个值为 hello 的新行在每个数据行之后。

Sub addrowwithvalue()
  m = Range("a1").CurrentRegion.Rows.Count
  For i = m To 2 Step -1
    Cells(i, 1).EntireRow.insert
    Next
End Sub

预期输出:
row1
hello
row2
hello
row3
hello

最佳答案

尝试插入行 Cells(i, 1).Value = "hello"紧接在 Next 之前.

更改mm + 1在最后的“你好”的第 3 行。

关于vba - 如何在 Excel 中包含数据的每一行之后插入特定值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21647639/

相关文章:

vba - 使用表单属性在用户表单上设置值

excel - 闪烁动画被 DoEvents 中断

mysql - 通过VBA将Excel中的数据添加到Mysql

excel - 导出到 Excel 时,SSRS 不支持 CanGrow 属性

excel - 将通配符添加到过滤器

vba - Excel/VBA : Is there a shape property I can set to prevent the shape from printing?

excel - VBA - 乘列

vba - 如何在Excel VBA中停止单元格滚动

vba - 设置 SentOn 的格式以仅显示日期

excel - 如果单元格 a1=文本,则单元格 a2=粗体。我如何在excel中做到这一点?