gpt4 book ai didi

excel - 如何将句子转换为单个单词的列/行

转载 作者:行者123 更新时间:2023-12-04 20:22:09 24 4
gpt4 key购买 nike

为什么它不起作用?
只打印第一个单词,我不知道如何将“For”中的“10”更改为“For each word in sentence”

 Sub Change()
Dim S As String
Dim i As Integer
Dim x As String


S = InputBox("Sentence")
x = Split(S, " ")
For i = 1 To x
Cells(1, i).Value = Split(S, " ")

Next i

End Sub

最佳答案

尝试这个:

Public Sub Change()
Dim sentence As String: sentence = InputBox("Sentence")
Dim col As Long: col = 1
Dim word As Variant: For Each word In Split(sentence, " ")
ThisWorkbook.Worksheets("Sheet1").Cells(1, col).Value = word
col = col + 1
Next
End Sub

关于excel - 如何将句子转换为单个单词的列/行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70138331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com