首页 文章

Excel公式中的“_”下划线

提问于
浏览
-1

当我尝试运行这些命令时,我遇到了问题 . 问题来自公式表达式,因为 "_" 是一个语法错误,但我需要在Excel单元格中完全使用该公式,

我怎么能解决它?

Sub Prueba_Fernando()
Application.ScreenUpdating = False
Range("B:B").Columns.Insert
    Range("B1").FormulaLocal = "=EXTRAE(A1;HALLAR("_";A1;2)+1;LARGO(A1)-HALLAR("_";A1;1))"
        Set h1 = Sheets("Hoja1")
        h1.Range("B1").Copy
        For Each h In Sheets
        u = h.Range("A" & Rows.Count).End(xlUp).Row
        h1.Range("B2:B" & u).PasteSpecial xlAll
        Next
        MsgBox "Fórmulas aplicadas"

Dim xColIndex As Integer
Dim xRowIndex As Integer
xIndex = Application.ActiveCell.Column
xRowIndex = Application.ActiveSheet.Cells(Rows.Count, xIndex).End(xlUp).Row
Range(Cells(3, xIndex), Cells(xRowIndex, xIndex)).Copy
Application.ScreenUpdating = True
MsgBox "Información copiada a Portapapeles"

End Sub

1 回答

  • 2

    你是对的,问题在于公式 .

    它是由 " 引起的,当你想在一个字符串里面有双排队时,你需要加倍它,否则它会被解释为字符串的结尾,从而出错 .

    使用此行:

    Range("B1").FormulaLocal = "=EXTRAE(A1;HALLAR(""_"";A1;2)+1;LARGO(A1)-HALLAR(""_"";A1;1))"
    

相关问题