作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Excel 中,我需要为批量上传生成文件,其中包含 1K、5K、10K 和 100K 行。所以我查看了 VBA 脚本。下面是:
Private Sub CommandButton21_Click()
' This routing will copy rows based on the quantity to a new sheet.
Dim rngSinglecell As Range
Dim rngQuantityCells As Range
Dim intCount As Integer
' Set this for the range where the Quantity column exists. This works only if there are no empty cells
Set rngQuantityCells = Range("D1", Range("D1").End(xlDown))
For Each rngSinglecell In rngQuantityCells
' Check if this cell actually contains a number
If IsNumeric(rngSinglecell.Value) Then
' Check if the number is greater than 0
If rngSinglecell.Value > 0 Then
' Copy this row as many times as .value cut out rngSinglecell DOT Value
For intCount = 1 To 1000
' Copy the row into the next emtpy row in sheet2
Range(rngSinglecell.Address).EntireRow.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
' The above line finds the next empty row.
Next
End If
End If
Next
End Sub
A15
的一行数据。至
Y15
,然后将其粘贴到工作表中,以便我可以将其复制粘贴回原始工作表(用于 iProcurement 中的批量上传)。
For intCount = 1 To 1000
最佳答案
据我所知,您正在尝试这样做-
Sub test()
' This routing will copy rows based on the quantity to a new sheet.
Dim lastrow As Integer
lastrow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
' Set this for the range where the Quantity column exists. This works only if there are no empty cells
Dim destlastrow As Integer
destlastrow = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
' The above line finds the next empty row.
For i = 1 To lastrow
' Check if this cell actually contains a number
If IsNumeric(Cells(i, 4)) Then
' Check if the number is greater than 0
If Cells(i, 4) > 0 Then
' Copy this row as many times as .value cut out rngSinglecell DOT Value
For j = 1 To Cells(i, 4).Value
' Copy the row into the next emtpy row in sheet2
Cells(i, 4).EntireRow.Copy Destination:=Sheets("Sheet2").Cells(destlastrow, 1)
destlastrow = destlastrow + 1
Next
End If
End If
Next
End Sub
关于vba - 在 Excel 中,如何生成行 X 次的副本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31595168/
我有一个大的包含元素,里面有大约十个 DIV - 大多数平均宽度约为 300 像素,并且都设置为向左浮动。最终结果是一个小部件/网格类型的布局。但是,这种样式是专门为响应式设计而构建的 - 我们使用媒
我想通过 \n 拆分字符串并将包含特定标记的行放入数组中。 我有这个代码: char mydata[100] = "mary likes apples\njim likes playing\n
我是一名优秀的程序员,十分优秀!