LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default VBA VLookup Problem: Run-Time error '1004'

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I get VLookup error 1004 KenG Excel Discussion (Misc queries) 2 March 28th 10 01:24 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
I got this problem run-time error 1004 application defined ... Davide Blau Excel Discussion (Misc queries) 2 July 10th 06 09:27 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM


All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"