I have a workbook with a number of similar sheets in which some cells contain a VBA formula, i.e. =newValue() . When I try to copy one of those sheets e.g. at the end of the same workbook, using the "Move or copy sheet" tab, the copy is done OK, but in ALL the other sheets, the value in the formula cells duplicate the values from the copied sheet. If I look at the contents of such a wrongly-duplicated cells, it shows the formula name, and not the value. This problem exists in Excel 2007 and Excel 2013. What shall be done to overcome the problem?
Here are relevant excerpts of the VBA code:
Function newValue() 'newValue(depCells)
curRow = Application.ThisCell.Row
curCol = Application.ThisCell.Column
curOp = Cells(curRow, 2).Value
If curCol = 4 Then
lastVal = Cells(lastRow, 4).Value
If curOp = "B" Then
newValue = lastVal + Cells(curRow, 3).Value
ElseIf curOp = "S" Then
newValue = lastVal - Cells(curRow, 3).Value
Else
newValue = ""
End If
ElseIf curCol = 6 Then ...
End If
End Function