I can't get my values from another workbok .
Please help and appreciated your effort.
Dim MaxRowNum As Integer
Sheets("SimPat").Select
'Counting number of rows
MaxRowNum = 1
Do While Cells(MaxRowNum, 2) <> "" Or Cells(MaxRowNum + 1, 2) <> ""
MaxRowNum = MaxRowNum + 1
Loop
Workbooks.Open ("C:\Users\marosario\Desktop\SimpatTest\SAPUSERMASTER.xls")
'Vlookup User Name and User Dept from the file SAPUSERMASTER.xls
'Range("P3").FormulaR1C1 = "=IF(C[-3]="""","""",IFERROR(VLOOKUP(C[-3],SAPUSERMASTER.xls!R[-2]C4:R[64990]C10,7,0),""NOT INDICATED""))"
'Range("P3").FormulaR1C1 = "=IF(C[-3]="""","""",IFERROR(VLOOKUP(C[-3],[SAPUSERMASTER.XLS]SAPUSERMASTER!("$1:$1048576"),2,0),""NOT INDICATED""))"
'Range("Q3").FormulaR1C1 = "=IF(C[-4]="""","""",IFERROR(VLOOKUP(C[-4],SAPUSERMASTER.xls!R[-2]C4:R[64990]C16,13,0),""NOT INDICATED""))"
Range("Q3").FormulaR1C1 = "=IF(C[-4]="""","""",IFERROR(VLOOKUP(C[-4],[SAPUSERMASTER.XLS]SAPUSERMASTER!$1:$1048576,3,0),""NOT INDICATED""))"
'AutoFill formula. Copy and paste data as value
Range("P3:Q3").Select
Selection.AutoFill Destination:=Range("P3:Q" & MaxRowNum), Type:=xlFillDefault
Columns("P:Q").Select
Columns("P:Q").EntireColumn.AutoFit
Columns("P:Q").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("P2").Select
End Sub
Bookmarks