G
Guest
Pasted below is code that when ran is resulting in a "Run-Time error '1004'
Unable to get the VLookup property of the WorksheetFunction Class." The
problem is in the string of code where I am trying to apply a password to a
file based on a result from a vlookup. Can someone help me get this
corrected, I believe I am very close...thanks.
Sub Protect_File_Labor()
Dim sCurrFName As String
Dim X As Integer
Dim Y As Range
Set Y = Range("d17")
With Application
.ScreenUpdating = False
.DisplayAlerts = False
sCurrFName = Dir(Y.Value & "*.xls")
Do While sCurrFName <> ""
Workbooks.Open (Y.Value & sCurrFName)
Workbooks(sCurrFName).SaveAs (Y.Value & sCurrFName),
Password:=WorksheetFunction.VLookup(sCurrFName, Range("k1:l3"), 2, 0)
Workbooks(sCurrFName).Close
sCurrFName = Dir
Loop
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
Unable to get the VLookup property of the WorksheetFunction Class." The
problem is in the string of code where I am trying to apply a password to a
file based on a result from a vlookup. Can someone help me get this
corrected, I believe I am very close...thanks.
Sub Protect_File_Labor()
Dim sCurrFName As String
Dim X As Integer
Dim Y As Range
Set Y = Range("d17")
With Application
.ScreenUpdating = False
.DisplayAlerts = False
sCurrFName = Dir(Y.Value & "*.xls")
Do While sCurrFName <> ""
Workbooks.Open (Y.Value & sCurrFName)
Workbooks(sCurrFName).SaveAs (Y.Value & sCurrFName),
Password:=WorksheetFunction.VLookup(sCurrFName, Range("k1:l3"), 2, 0)
Workbooks(sCurrFName).Close
sCurrFName = Dir
Loop
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub