下記のマクロをフォルダ内に対象Excelがある限りロープさせるにはどのような式を追加したら良いのでしょうか? よろしくお願いします。 Sub 実行() Application.ScreenUpdating = False Dim desktop As String, file As String, wb As Workbook, WS As Worksheet desktop = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "フォルダ" & "\" file = Dir(desktop & "*価格*.xlsx") Set wb = Workbooks.Open(desktop & file) Range("A:A,R:S").Insert Range("A1") = "CON" Range("S1") = "仕入単価" & Chr(10) & "(現状)" Range("T1") = "仕入単価" & Chr(10) & "(改定)" With Worksheets("ZR") .Range("A2:A" & .Cells(.Rows.Count, "E").End(xlUp).Row).FormulaR1C1 = "=CONCATENATE(RC[3],RC[9])" .Range("S2:S" & .Cells(.Rows.Count, "E").End(xlUp).Row).FormulaR1C1 = "=IF(ISERROR(VLOOKUP(CONCATENATE(MID(RC[4],4,5),RC[-9]),C[-18]:C[-2],16,0)),"""",VLOOKUP(CONCATENATE(MID(RC[4],4,5),RC[-9]),C[-18]:C[-2],16,0))" .Range("T2:T" & .Cells(.Rows.Count, "E").End(xlUp).Row).FormulaR1C1 = "=IF(ISERROR(VLOOKUP(CONCATENATE(MID(RC[3],4,5),RC[-10]),C[-19]:C[-3],17,0)),"""",VLOOKUP(CONCATENATE(MID(RC[3],4,5),RC[-10]),C[-19]:C[-3],17,0))" .Range("A2:T" & .Range("E" & .Cells.Rows.Count).End(xlUp).Row).Copy .Range("A2:T" & .Range("E" & .Cells.Rows.Count).End(xlUp).Row).PasteSpecial Paste:=xlPasteValues End With Columns("A:A").Delete Range("R1:S1").Interior.ThemeColor = xlThemeColorAccent5 Range("R1:S1").Interior.TintAndShade = 0.599993896298105 Range("A1").Select ActiveWorkbook.Save ActiveWindow.Close End Sub
Visual Basic