我的代码一直只给我Sheet1.Cells(3,1)的结果。它使用顺序i输出到正确的单元格,但始终来自(3,1)中的相同输入。如何让它循环遍历第一列(3,1),(4,1)(5,1)等的输入?
Sub CorrectName()
Dim IndexAnswers() As String
Dim FirstLastName As String
Dim FirstLastNameSplit() As String
i = 3
While Sheet1.Cells(i, 1) <> ""
IndexAnswers() = Split(Sheet1.Cells(i, 1), ";")
For k = 0 To UBound(IndexAnswers)
If IndexAnswers(k) = "" Then IndexAnswers(k) = ","
If k > 107 And k < 132 Then
FirstLastName = FirstLastName & IndexAnswers(k)
End If
Next
FirstLastNameSplit() = Split(FirstLastName, ",")
Sheet1.Cells(i, 4) = FirstLastNameSplit(0)
Sheet1.Cells(i, 3) = FirstLastNameSplit(1) & FirstLastNameSplit(2)
i = i + 1
Wend
End Sub