Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Vlookup Two Workbooks #N/A Error

Posted on 2013-06-11
4
Medium Priority
?
248 Views
Last Modified: 2013-06-11
The two workbooks are "PFA.xlsm", which holds the macro, and "Weekly Reports.xls", which holds the data. Both workbooks are open and stored on the I drive.

The macro is run on "Weekly Reports" to lookup a number and return a name.

The macro is:

Sub RefLookUp()
'
' RefLookUp Macro
'
Range("A:A").Select
     Range("A2:A" & Cells(65336, "B").End(xlUp).Row).Select
     Selection.Formula = "=VLOOKUP(G2,'[I:\WHSE\BDG\Curt\PFA.xlsm]SheetAPF'!$A$2:$B$65336,2,FALSE)"

End Sub

After running the macro #N/A is returned and the value in Cell A2 is:

=VLOOKUP(G2,'[I:\WHSE\BDG\Curt\[PFA.xlsm],SheetAPF]PFA.xlsm],SheetAPF'!$A$2:$B$65336,2,FALSE)
Weekly-Report.xls
PFA.xlsm
0
Comment
Question by:Tosagua
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:Tosagua
ID: 39237873
Sorry about that, the question was submitted with zero points and should be 500.

Any assistance or insight would be appreciated.

Tosagua
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 39237889
1. Try this macro

Sub RefLookUp()
'
' RefLookUp Macro
'
Range("A2:A60000").Select
     
     Selection.Formula = "=VLOOKUP(G2,'[PFA.xlsm]SheetAPF'!$A$2:$B$65336,2,FALSE)"

End Sub

Open in new window


2. Both workbooks must be open to get results.
0
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39237898
Hi

Sub RefLookUp()
'
' RefLookUp Macro
'
     Range("A2:A" & Cells(65336, "B").End(xlUp).Row).Select
     Selection.Formula = "=VLOOKUP(G2,'[PFA.xlsm]APF'!$A$2:$B$65336,2,FALSE)"

End Sub

Open in new window

The APF Sheet is adressed wrong (only APF)

Regards
0
 

Author Closing Comment

by:Tosagua
ID: 39237994
Rgonzo1971,

Works perfectly.

The prior solution returned a "Run-time error '1004: Application-defined or object-defined error".

I appreciate both responses.

Thank you very much.

Tosagua
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question