【问题标题】:Excel formula. Spreadsheet formulaExcel 公式。电子表格公式
【发布时间】:2016-02-14 08:52:42
【问题描述】:

以下是在每个单词之前放置数字。是否有任何相同的公式可以从电子表格中每个单词的开头删除数字。这是公式how to insert numbers before every word in excel的链接

Sub test()
    Dim cl As Range, i&
    Set cl = Cells.Find("*")
    For i = 1 To WorksheetFunction.CountA(Cells)
        If Not cl Is Nothing Then
            cl.Value2 = i & "/" & cl.Value2
            Set cl = Cells.FindNext(cl)
        Else
            Exit For
        End If
    Next i
End Sub

【问题讨论】:

标签: excel-formula spreadsheet


【解决方案1】:

使用相同的代码,但不要插入数字,而是将其删除

Sub test()
Dim cl As Range, i&
Set cl = Cells.Find("*")
For i = 1 To WorksheetFunction.CountA(Cells)
    If Not cl Is Nothing Then
        cl.Value2 = RIGHT(cl.Value2,LEN(cl.Value2)-InStr(cl.Value2, "/")-1)
        Set cl = Cells.FindNext(cl)
    Else
        Exit For
    End If
Next i
End Sub

【讨论】:

  • 感谢回复,但运行上述公式时显示错误
  • 把find函数改成InStr,搜索第一个“/”的位置
猜你喜欢
  • 1970-01-01
  • 2023-03-27
  • 2020-07-24
  • 1970-01-01
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 2019-04-15
相关资源
最近更新 更多