VBA code paste as text not formula problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
1,682
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
31,986
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,081,530
Messages
5,359,347
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top