For some reason after cell 488 the function stops copying correctly. After 488 all the way to the end (about row 1,000) it pulls from the same cell all the way to the bottom.
Any way to make this code more robust so that it will always pull from the cell in the same row?
If I need to clarify please let me know, i would be happy to elaborate however necessary.
Sub Compare()
Dim lastRow As Long
With Sheets("MP Parameters")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).row
Range("A1").EntireColumn.Insert
With .Range("A5:A" & lastRow)
.Formula = "=MID(B5,FIND(""¬"",SUBSTITUTE(B5,""-"",""¬"",3))+1,LEN(B5))"
.Value = .Value
End With
End With
End Sub
You are converting to value before calculation completed.
As cyboashu stated you are converting before calculation is completed which is causing the problem.
However you are first placing the
Formula
to theCell
and then copying theValue
into theCell
. This can be shortened to letting VBA calculate theValue
and place it into theCell
.The functionality of the above code is tested and works.