fluffyvampirekitten
Board Regular
- Joined
- Jul 1, 2015
- Messages
- 72
I am having problems with the code listed below.
I'm trying to use indexmatch with another workbook to get the values and save the value as cell values .
But it returns a value of #N/A.
I want a to save it as paste cell value only and not formula
Can anyone suggest a solution? or please tell me whats went wrong with the code .


I'm trying to use indexmatch with another workbook to get the values and save the value as cell values .
But it returns a value of #N/A.
I want a to save it as paste cell value only and not formula

Can anyone suggest a solution? or please tell me whats went wrong with the code .


Code:
Private Sub Unsuccessful()
'Update Column S and T
'S = Active Ext ID , T = Inactive Ext ID
Dim MaxRowNum As Long
Sheets("SimPat").Select
'Set up an Error handler
On Error GoTo errorFound
Err.Clear
On Error GoTo 0
'Speed up the formula
With Application
.ScreenUpdating = False
.Calculation = xlManual
End With
'Vlookup/IndexMatch Active Ext ID
Range("S2").FormulaR1C1 = _
"=INDEX('[PatientMerge.xls]2015'!C10,MATCH(C[-16],'[PatientMerge.xls]2015'!C10,0))"
'Vlookup/IndexMatch Inactive Ext ID
Range("T2").FormulaR1C1 = _
"=INDEX('[PatientMerge.xls]2015'!C11,MATCH(C[-17],'[PatientMerge.xls]2015'!C11,0))"
' Locate last filled row in column S (this instead of the loop)
MaxRowNum = Range("A" & Rows.Count).End(xlUp).Row
'Autofill the rest of the rows
Range("S2:T2").Select
Selection.AutoFill Destination:=Range("S2:T" & MaxRowNum), Type:=xlFillDefault
'Column S and T Autofit
Columns("S:T").Select
Columns("S:T").EntireColumn.AutoFit
'Copy and Paste data as value
'Columns("S:T").Select
'=================================================
' Errors on Paste formulae/code
'=================================================
Range("S2:T" & MaxRowNum).Select
Selection.Copy
Worksheets("Simpat").Range("S2:T" & MaxRowNum).PasteSpecial xlPasteValues
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("S2").Select
'Close the speed up
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
'Close the error Handler
Exit Sub
errorFound:
If Err.Number > 0 Then MsgBox Err.Description, vbCritical, "Error#: & Err.Number"
Err.Clear
End Sub