嗨,我想在行中按顺序将单元格粘贴到模板上的特定单元格值,同时为每行创建一个新的模板表。
视觉上,我需要以下信息:
像这样输入模板:
要实现此目标,我需要在下面添加什么?该行按我要提取的顺序进行,只需要帮助组织脚本即可。
我有以下VBA脚本:
Sub distribute()
Dim sh As Worksheet
Dim k As Long, i As Integer
Set sh = ThisWorkbook.Sheets("Data")
k = sh.Range("A1048576").End(xlUp).Row
For i = 1 To k
Worksheets("Template").Copy After:=Sheets(Sheets.Count)
sh.Rows(i).Copy Range("A2")
Next
End Sub
谢谢StackOverflow!
这很感谢GMalc!
Sub distribute()
Dim sh As Worksheet
Dim k As Long, i As Integer
Set sh = ThisWorkbook.Sheets("Data")
k = sh.Range("A1048576").End(xlUp).Row
For i = 2 To k
With Worksheets("Template")
.Cells(3,2).Value = sh.Cells(i,1).Rows()
.Cells(3,4).Value = sh.Cells(i,2).Rows()
.Cells(8,4).Value = sh.Cells(i,3).Rows()
.Cells(5,2).Value = sh.Cells(i,4).Rows()
.Copy After:=Sheets(Sheets.Count)
End With
Next i
End Sub
答案 0 :(得分:0)
尝试一下。
--tag=CXX