更新时间:2023-02-04 19:58:50
以下是帮助您入门的示例.
Here is an example to get you started.
此代码将获取您突出显示的活动单元格,并用空格将字符串分解,将其扩展到第1行的各列.
This code will take the active cell you have highlighted and break up the string by spaces, expanding it across columns in row 1.
示例:
代码将执行,您现在在A1中具有"Hello",在A2中具有"World",在A3中具有"Test"
The code will execute and you will now have "Hello" in A1, "World" in A2, and "Test" in A3
Sub Example()
Dim txt As String
Dim i As Integer
Dim fullname As Variant
txt = ActiveCell.Value
fullname = Split(txt, " ")
For i = 0 To UBound(fullname)
Cells(1, i + 1).Value = fullname(i)
MsgBox fullname(i)
Next i
End Sub