VBA code paste as text not formula problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,678
I have code that was running great for more than a year. Now its adding in the formula as text so its not doing the calculation any longer
"=IFERROR((INDEX(Detail!C[-2],MATCH(CMOP!RC[-1],Detail!C[-2],0))),""DELETE"")"

Any help is appreciated

Code:
Sub StripDown()
'
' Macro1 Macro
'
    If Not Evaluate("isref('CMOP'!a1)") Then
                MsgBox "You Did not import the CMOP"
                UserForm1.Hide
                'CMOP.Close False
                Exit Sub
                
    Else


    Dim LstRw As Long
'
    Sheets("CMOP").Select
    
    LstRw = Sheets("CMOP").Range("B" & Rows.Count).End(xlUp).Row
    
    Columns("C:C").Select
    Selection.Insert Shift:=xlToRight
    Range("C4").FormulaR1C1 = _
        "=IFERROR((INDEX(Detail!C[-2],MATCH(CMOP!RC[-1],Detail!C[-2],0))),""DELETE"")"
    Range("C4").Select
    Selection.Copy
    
    Range("C4:C" & LstRw).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("C2").Select
    
    Calculate
    
    Dim lr As Long
    
    lr = Cells(Rows.Count, "C").End(xlUp).Row
    
    With Range("C4:C" & lr)
        .AutoFilter
        .AutoFilter Field:=1, Criteria1:="Delete"
            .SpecialCells(xlCellTypeVisible).EntireRow.Delete
    End With
    
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    
    Range("A4").Select
    
    End If
    
    
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,253
Office Version
365
Platform
Windows
Replace this
Code:
    Columns("C:C").Select
    Selection.Insert Shift:=xlToRight
    Range("C4").FormulaR1C1 = _
        "=IFERROR((INDEX(Detail!C[-2],MATCH(CMOP!RC[-1],Detail!C[-2],0))),""DELETE"")"
    Range("C4").Select
    Selection.Copy
    
    Range("C4:C" & LstRw).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Range("C2").Select
with
Code:
    Columns("C").Insert Shift:=xlToRight
    Columns("C").NumberFormat = "General"
    Range("C4:C" & LstRw).FormulaR1C1 = _
        "=IFERROR((INDEX(Detail!C[-2],MATCH(CMOP!RC[-1],Detail!C[-2],0))),""DELETE"")"
    Range("C2").Select
 

Forum statistics

Threads
1,077,855
Messages
5,336,782
Members
399,102
Latest member
chudson1

Some videos you may like

This Week's Hot Topics

Top