I want to display the data without the formulas after running the indexmatch formula.
However, it shows #N/A as values.
At first, without the codes of copy/paste data as value ,
It still shows the data
But after i wrote the 'Copy and Paste data as value
All the cell shows "#N/A" as values .
Anyone please help me .
I dont know where my code went wrong .
Private Sub Unsuccessful()
'Update Column S and T
'S = Active Ext ID , T = Inactive Ext ID
Dim MaxRowNum As Long
Sheets("SimPat").Select
'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[-16],'[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
' Range("S2").AutoFill Destination:=Range("S2:S" & MaxRowNum)
Selection.AutoFill Destination:=Range("S2:T" & MaxRowNum), Type:=xlFillDefault
'Copy and paste data as value
Columns("S:T").Select 'error in this line
Columns("S:T").EntireColumn.AutoFit
Columns("S:T").Select
Selection.Copy
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
Bookmarks