Philip1957
Board Regular
- Joined
- Sep 30, 2014
- Messages
- 182
- Office Version
- 365
- Platform
- Windows
Greetings,
I am trying to write a macro that will perform a Vlookup using a named range in one workbook as the Table Array to populate a column in a named range in a second workbook. I can't seem to get past declaring & setting my variables. This is also my first attempt at doing a Vlookup with VBA.
wb1 is the workbook I'm running the macro from. I define this because in other parts of the project I am using relative path references to locate other file (like the two I'm trying to Vlookup)
wb3 is the workbook I need to run the Vlookup in to populate the second column in the named range.
wb4 is the workbook with the named range that I want to use as the Table Array.
Here's what little code I have so far:
The activate & select at the end were simply to test out my variables.
The 2 workbooks, IP Lookup & IP_Master, are already open. When I try to set them I get a "Compile Error: Type Mismatch" and I don't understand why.
Any assistance would be greatly appreciated.
~ Phil
I am trying to write a macro that will perform a Vlookup using a named range in one workbook as the Table Array to populate a column in a named range in a second workbook. I can't seem to get past declaring & setting my variables. This is also my first attempt at doing a Vlookup with VBA.
wb1 is the workbook I'm running the macro from. I define this because in other parts of the project I am using relative path references to locate other file (like the two I'm trying to Vlookup)
wb3 is the workbook I need to run the Vlookup in to populate the second column in the named range.
wb4 is the workbook with the named range that I want to use as the Table Array.
Here's what little code I have so far:
VBA Code:
Private Sub IP_Vlook_Master_to_Lookup()
'Lookup the IP address in IP Master, copy to IP Lookup
Dim wb1 As Workbook
Set wb1 = ThisWorkbook
Dim wb3 As Workbook
Set wb3 = ("IP Lookup")
Dim wb4 As Workbook
Set wb4 = ("IP_Master")
wb3.Activate
Range.IPL_tbl!(2, 2).Select
End Sub
The activate & select at the end were simply to test out my variables.
The 2 workbooks, IP Lookup & IP_Master, are already open. When I try to set them I get a "Compile Error: Type Mismatch" and I don't understand why.
Any assistance would be greatly appreciated.
~ Phil