对任何可以提供帮助的人......提前致谢。
项目编号、包装和尺寸的每一行都需要根据“标签数量”列中的数字在单独的工作表中重复多次
(请注意:标签数量中的数字仅用于测试目的,不需要递增)
表 1 如下所示
Item # Pack Size Number of Labels
12545 20 1.8oz 1
56010 6 4PK 2
70091 6 7oz 3
61816 24 1.6oz 4
4
我希望工作表 2 输出如下内容:
Item # Pack Size
12545 20 1.8oz
56010 6 4PK
56010 6 4PK
70091 6 7oz
70091 6 7oz
70091 6 7oz
61816 24 1.6oz
61816 24 1.6oz
61816 24 1.6oz
61816 24 1.6oz
我找到了以下代码,但我希望单元格输入范围是固定的并且不使用对话框我需要帮助修改我找到的代码以解决我给定的问题。我需要以下代码来输出多个colomns。:(我在这里得到了代码:https : //www.extendoffice.com/documents/excel/1897-excel-repeat-cell-value-x-times.html#a2)
Sub CopyData()
'Update 20140724
Dim Rng As Range
Dim InputRng As Range, OutRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
Set OutRng = OutRng.Range("A1")
For Each Rng In InputRng.Rows
xValue = Rng.Range("A1").Value
xNum = Rng.Range("B1").Value
OutRng.Resize(xNum, 1).Value = xValue
Set OutRng = OutRng.Offset(xNum, 0)
Next
End Sub
我试图做的黑客攻击没有任何帮助会很棒。
背景:我必须在我的工作中为新产品创建许多标签。我必须在 Word 中手动输入每个标签。我发现我可以使用Words Mail合并操作来导入excel数据。我让这些部件正常工作,但现在我需要能够获得每个项目所需的确切标签数量。
Private Sub hereyago()
Dim arr As Variant
Dim wsO As Worksheet
Dim this As Integer
arr = ThisWorkbook.Sheets("Sheet1").UsedRange
Set wsO = ThisWorkbook.Sheets("Sheet2")
For i = LBound(arr, 1) To UBound(arr, 1)
If IsNumeric(arr(i, 4)) Then
this = arr(i, 4)
For h = 1 To this
wsO.Cells(wsO.Rows.count, 1).End(xlUp).Offset(1, 0).Value = arr(i, 1)
wsO.Cells(wsO.Rows.count, 1).End(xlUp).Offset(0, 1).Value = arr(i, 2)
wsO.Cells(wsO.Rows.count, 1).End(xlUp).Offset(0, 2).Value = arr(i, 3)
wsO.Cells(wsO.Rows.count, 1).End(xlUp).Offset(0, 3).Value = arr(i, 4)
Next h
End If
Next i
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句