根据月份导入特定工作表

时间:2018-03-20 16:48:25

标签: excel vba excel-vba

我有这个宏,当我输入部分和年份和月份时导入所需的工作表。 如何添加(从月份)和(到月份)以显示所需的工作表?

非常感谢

Sub macro()

Workbooks.Add
wb1 = ActiveWorkbook.Name

quantitiy_of_productions = "O:\LF\07M\JL\"

Section = ThisWorkbook.Worksheets("w1").Range("Section")
Year = ThisWorkbook.Worksheets("w1").Range("Year")
From_Month = ThisWorkbook.Worksheets("w1").Range("From_Month")
To_Month = ThisWorkbook.Worksheets("w1").Range("To_Month")

For i = 1 To 12

Filename = "QP_Sec" & Section & ".xlsx"
Workbook.Open Filename:=Quantity_of_productions & "QP" & Year & "\" &       filename, ReadOnly:=True, IgnoreReadOnlyRecommended:=True

Workbooks(Filename).Close False

Next i

0 个答案:

没有答案