VBA code paste as text not formula problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,690
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
32,317
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,082,323
Messages
5,364,579
Members
400,809
Latest member
formulasataglance

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top