【发布时间】:2022-10-24 02:36:44
【问题描述】:
我的代码需要帮助,该代码显示一个输入框,用户输入一个名称,然后代码拆分名称并计算显示以下内容的名称:
Sub ParseName()
Dim Name As String
Dim Count As Integer
Dim Cell As Object
Dim n As Integer
Count = 0
Name = InputBox("Enter First Name, Middle Name, and Last Name")
If Name = "" Then
For Each Cell In Selection
n = InStr(1, Cell.Value, Name)
While n <> 0
Count = Count + 1
n = InStr(n + 1, Cell.Value, Name)
Next Cell
MsgBox Count & " Occurrences of " & Name
End If
End Sub
【问题讨论】:
-
在代码行的哪里?
-
我正在尝试获取一个使用输入框的代码,该输入框要求用户输入全名。示例:杰夫·艾伦·乔恩斯。从那里我需要将名称拆分为第一个、中间和最后一个。从那里它需要计算字符减去空格并显示如上图所示的 MsgBox。这计算全名的字符数并计算名字和姓氏的字符。
-
我希望这是有道理的
-
不,这是严格的 VBA 纯编码,没有 excel 单元格操作。
-
我希望这会有所帮助,因为我现在有点失落
标签: excel vba excel-formula