Sub main()
Dim n, i As Long
n = 50
For i = 1 To n
u (i)
Next
End Sub
Sub u(i)
Dim pos As Long
Dim str1, str2 As String
'ActiveSheet.Cells(i, 3) = ActiveSheet.Cells(i, 2)
pos = InStr(Sheet1.Cells(i, 3), ",")
If pos > 0 Then
Sheet1.Rows(i + 1).Insert
str1 = Left(Sheet1.Cells(i, 3), pos - 1)
str2 = Right(Sheet1.Cells(i, 3), Len(Sheet1.Cells(i, 3)) - pos)
ActiveSheet.Cells(i + 1, 1) = ActiveSheet.Cells(i, 1)
ActiveSheet.Cells(i + 1, 2) = str1
ActiveSheet.Cells(i + 1, 3) = str2
'Sheet1.Cells(i + 1, 1) = Sheet1.Cells.Range(i, 1)
Else
ActiveSheet.Cells(i + 1, 3) = ActiveSheet.Cells(i + 1, 2)
i = i + 1
End If
End Sub
vba 数据处理
最新推荐文章于 2024-01-28 22:59:13 发布