Jud*_*nna 4 excel automation vba rows duplicates
我试图以一种能够节省数不清的繁琐数据输入的方式自动化Excel.这是我的问题.
我们需要打印所有库存的条形码,其中包括4,000个变量,每个变量都有特定的数量.
Shopify是我们的电子商务平台,不支持定制出口; 但是,可以导出所有变体的CSV,其中包括库存盘点列.
我们使用Dymo作为条形码打印硬件/软件.Dymo每行只打印一个标签(忽略数量列).
有没有办法根据库存列中的值自动执行excel复制行"x"次?
这是一个数据样本:
我试图找到一个做过类似事情的人,以便我可以修改代码,但经过一个小时的搜索,我仍然在我开始的地方.提前感谢您的帮助!
大卫打败了我,但另一种方法从来没有伤害任何人.
请考虑以下数据
Item Cost Code Quantity
Fiddlesticks 0.8 22251554787 0
Woozles 1.96 54645641 3
Jarbles 200 158484 4
Yerzegerztits 56.7 494681818 1
Run Code Online (Sandbox Code Playgroud)
有了这个功能
Public Sub CopyData()
' 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
For intCount = 1 To rngSinglecell.Value
' 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
Run Code Online (Sandbox Code Playgroud)
在sheet2上生成以下输出
Item Cost Code Quantity
Woozles 1.96 54645641 3
Woozles 1.96 54645641 3
Woozles 1.96 54645641 3
Jarbles 200 158484 4
Jarbles 200 158484 4
Jarbles 200 158484 4
Jarbles 200 158484 4
Yerzegerztits 56.7 494681818 1
Run Code Online (Sandbox Code Playgroud)
使用此代码的警告是"数量"列中不能有空字段.我用过D,所以请随意用N代替你的情况.
| 归档时间: |
|
| 查看次数: |
52152 次 |
| 最近记录: |