VLOOKUP from closed sheet

MACY8167

New Member
Joined
Nov 11, 2009
Messages
21
The below Macro is used to find a value from a closed sheet and return it to the open sheet. Whe the "closed sheet" is closed the lookup can find some but not all of the values. If the "closed" sheet is opened all of the values are returned. I am really curious as to why this happens




Rows("1:1").Select
Selection.Insert Shift:=xlDown
Range("A1").Select
ActiveCell.FormulaR1C1 = "Invoice #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Contact"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Date"
Range("D1").Select
ActiveCell.FormulaR1C1 = "VPO #"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Customer #"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Batch"
Range("B2").Select
ActiveWorkbook.Names.Add Name:="Contact", RefersToR1C1:= _
"=[formpref.xls]Sheet1!C1:C4"

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[2],contact,2,0)"
Range("B2").Select
Selection.Copy
[B2].Copy Range("B3", Range("A65536").End(xlUp).Offset(, 1))
Range("A2").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="#N/A"
Range("A6").Select
With ActiveSheet.PageSetup
.PrintGridlines = True
End With
End Sub

Any ideas?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top