我在论坛上四处看了看,但找不到足够的信息才能成功。在整个过程中感谢您的帮助。
顶部似乎有效,但当我到达range.formula
部分时,它无法正常工作。我试图引用具有变量名称的工作表,然后填写公式。为了确保公式一直到底,我将它引用到C列,因为它总是有没有空格的数据。
Sub SubName()
If (Worksheets("Master Data").AutoFilterMode And _
Worksheets("Master Data").FilterMode) Or _
Worksheets("Master Data").FilterMode Then
Worksheets("Master Data").ShowAllData
End If
Dim curDate As String, Fname As String
curDate = Format(Date, "yyyy-mm-dd")
Dim wba As Workbook
Fname = "Y:\Consumables\Company\ABC\DMC - Planning & Materials\On Hand Reports\ABC Site\" & _
curDate & "_INV_R12_ABC_Onhandreport.xlsx"
Set wba = Workbooks.Open(Filename:=Fname, UpdateLinks:=False, Notify:=False)
Dim wb As Workbook
For Each wb In Application.Workbooks
If wb.Name Like "*PFEP*" Then wb.Activate
Next wb
Sheets("Master Data").Select
Range("AL8:AL" & Cells(Rows.Count, "C").End(xlUp).Row).Formula = _
"=SUMIF('[" &_INV_R12_ABC_Onhandreport.xlsx & "]Sheet'!C2,RC[-35],'[" & INV_R12_ABC_Onhandreport.xlsx & "]Sheet'!C17)"
End Sub