Sub CopyPasteData()
DataDir = "C:\My Documents\Test\"
ChDir (DataDir)
File = Dir("*.xlsm")
While Nextfile <> ""
For Each f MasterWB.Names("nameList").RefersToRange
If f = File Then
newValues = MasterWB.Sheets("Master").Range("L4:U4").Value
Workbooks.Open (File)
Workbooks(Nextfile).Sheets("Report1").Unprotect Password:="qwedsa"
Workbooks(Nextfile).Sheets("Report1").Range("H10:R10") = newValues
Workbooks(File).Protect Password:="qwedsa"
Workbooks(File).Save
Workbooks(File).Close
End If
Next fileCell
Nextfile = Dir()
Wend
End Sub
I can't seem to iterate through the named range and appropriately copy and paste the lookup values between workbooks. I'm not sure how to make my loops work. How do I make this code to work?