Hi
I need to copy and paste a formula (highlighted in bold) to all the .xlsm files in a specific directory. The process works but I am getting a #NAME? error.
The dynamic name ranges refer to a workbook called Figure the deal2.xslm
Private Sub CommandButton1_Click()
MyDir = ActiveWorkbook.Path
DataDir = MyDir & "\Job Cards\"
ChDir (DataDir)
Nextfile = Dir("*.xlsm")
While Nextfile <> ""
Workbooks.Open (Nextfile), WriteResPassword:="*********"
Workbooks(Nextfile).Sheets("Sheet1").Range("c5") = "=VLOOKUP($I$4,Table,MATCH('[Figure the deal2.xlsm]StockSheet'!B$1,ColumnLabel,0),FALSE)"
Workbooks(Nextfile).Save
Workbooks(Nextfile).Close
Nextfile = Dir()
Wend
End Sub
Any ideas how to get it to work?
I need to copy and paste a formula (highlighted in bold) to all the .xlsm files in a specific directory. The process works but I am getting a #NAME? error.
The dynamic name ranges refer to a workbook called Figure the deal2.xslm
Private Sub CommandButton1_Click()
MyDir = ActiveWorkbook.Path
DataDir = MyDir & "\Job Cards\"
ChDir (DataDir)
Nextfile = Dir("*.xlsm")
While Nextfile <> ""
Workbooks.Open (Nextfile), WriteResPassword:="*********"
Workbooks(Nextfile).Sheets("Sheet1").Range("c5") = "=VLOOKUP($I$4,Table,MATCH('[Figure the deal2.xlsm]StockSheet'!B$1,ColumnLabel,0),FALSE)"
Workbooks(Nextfile).Save
Workbooks(Nextfile).Close
Nextfile = Dir()
Wend
End Sub
Any ideas how to get it to work?