对此非常陌生,因此将其视为挑战。我有一个主表,其中列A具有所有文件名(完整的文件名扩展名为.xls)。我需要复制此工作表中列b的数据并将其粘贴到特定选项卡中特定文件夹中的所有文件中。一个名称可以有多个项目。样本数据
Australia.xlsx XX
Austria.xlsx YY
Austria.xlsx DD
Belgium.xlsx OO
Brazil.xlsx MM
Brazil.xlsx NN
这是我试写的代码:
Sub Macro1()
Application.DisplayAlerts = False
Dim Country As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
k = 2
For i = 2 To 50
Windows("try 1 split to combines").Activate
Country = Worksheets("Sheet3").Cells(i, 1).Value
Workbooks("try 1 split to combines").Sheets("Sheet3").Range(Cells(i, i + 1)).Copy
Workbooks.Open Filename:= _
"C:\Users\abhayl.INDIA\Desktop\For Primary Team\For Primary Team\" & Country & " "
'Workbooks("Name").Activate
ActiveWorkbook.Sheets("Specific Questions").Activate
ActiveWorkbook.Sheets("Specific Questions").Cells(k, 2).xlPasteValues
finalrow2 = 42 + k
k = finalrow2 + 1
Workbooks(Country).Sheets("Specific Questions").Activate
Workbooks(Country).Close SaveChanges:=False
Next i
End Sub
这是非常基本但需要一些改进,任何人都可以帮助我更好地重写此代码吗?