Error 1004 FormulaLocal with SEERRO

2019-07-31 17:01发布

I am trying to use vba to insert a formula into cell on my Sheet. I believe it can be done with the formula I have below, but unfortunately I do not know how to fix my syntax below.

What's wrong with my FormulaLocal syntax?

The strange thing is that using R.Formula, it works, but the cell gets the error #NAME

   Sub InsertIFERROR()
        Dim R As Range
        Set R = Application.InputBox("Select a range", "Get Range", Type:=8)
        R.Select
        For Each R In Selection.SpecialCells(xlCellTypeFormulas)

            R.FormulaLocal = "=SEERRO(" & Mid(R.FormulaLocal, 2) & ",""-"")"

        Next R
    End Sub

2条回答
地球回转人心会变
2楼-- · 2019-07-31 17:27

Be especially careful about the regional version of your Excel. The PT-PT version uses SE.ERRO with a semicolon as a list separator while the PT-BR version uses SEERRO (and typically a comma as a list separator).

查看更多
可以哭但决不认输i
3楼-- · 2019-07-31 17:40

Try this....Hope it will work and make sense where you done mistake.

Sub InsertIFERROR()
    Dim R As Range
    Set R = Application.InputBox("Select a range", "Get Range", Type:=8)
    'R.Select
    For Each rCell In R.SpecialCells(xlCellTypeFormulas)

        rCell.FormulaLocal = "=SEERRO(" & Mid(rCell.FormulaLocal, 2) & ",""-"")"

    Next rCell
End Sub
查看更多
登录 后发表回答