两列数据拆分(拆分列怎么弄)
在生活中,很多人可能想了解和弄清楚实例41 拆分中文英文数字,42 两列交叉合并,43 一列交叉拆分为两列的相关问题?那么关于两列数据拆分的答案我来给大家详细解答下。
实例41-拆分中文英文数字
Private Sub CommandButton处理_Click()
With Worksheets(&34;)
.Columns(2).ClearContents
.Columns(3).ClearContents
.Columns(4).ClearContents
For i = 1 To .Range(&34;).End(xlUp).Row
If .Cells(i, 1) <> &34; Then
.Cells(i, 2) = 提取中文(.Cells(i, 1))
.Cells(i, 3) = 提取英文(.Cells(i, 1))
.Cells(i, 4) = 提取数字(.Cells(i, 1))
End If
Next i
.Activate
End With
End Sub
Function 提取中文(ByVal extractdata As String) As String
提取中文 = &34;
Dim extrattext As String
Dim ei As Long
Dim itemchar As String
Dim extract_array() As String
Dim extract_i
For ei = 1 To Len(extractdata)
itemchar = Mid(extractdata, ei, 1)
If itemchar Like &34; Then
extrattext = extrattext & itemchar
End If
Next ei
提取中文 = extrattext
End Function
Function 提取数字(ByVal extractdata As String) As String
提取数字 = &34;
Dim extrattext As String
Dim ei As Long
Dim itemchar As String
Dim extract_array() As String
Dim extract_i
For ei = 1 To Len(extractdata)
itemchar = Mid(extractdata, ei, 1)
If IsNumeric(itemchar) Then
extrattext = extrattext & itemchar
End If
Next ei
提取数字 = extrattext
End Function
Function 提取英文(ByVal extractdata As String) As String
提取英文 = &34;
Dim extrattext As String
Dim ei As Long
Dim itemchar As String
Dim extract_array() As String
Dim extract_i
For ei = 1 To Len(extractdata)
itemchar = Mid(extractdata, ei, 1)
If itemchar Like &34; Then
extrattext = extrattext & itemchar
End If
Next ei
提取英文 = extrattext
End Function
实例42-两列交叉合并
Private Sub CommandButton处理_Click()
With ThisWorkbook.Worksheets(&34;)
If Trim(.Cells(2, &34;).Value) = &34; Or Trim(.Cells(5, &34;).Value) = &34; Then
MsgBox &34;
Exit Sub
End If
&34;C&34;C&39;处理
Dim i
Dim addcount As Long
With ThisWorkbook.Worksheets(&34;)
.Columns(1).ClearContents
For i = startrow To stoprow
addcount = addcount + 1
.Cells(addcount, 1) = ThisWorkbook.Worksheets(&34;).Cells(i, 1)
addcount = addcount + 1
.Cells(addcount, 1) = ThisWorkbook.Worksheets(&34;).Cells(i, 2)
Next i
.Activate
End With
End Sub
实例43-一列交叉拆分为两列
Private Sub CommandButton处理_Click()
With ThisWorkbook.Worksheets(&34;)
If Trim(.Cells(2, &34;).Value) = &34; Or Trim(.Cells(5, &34;).Value) = &34; Then
MsgBox &34;
Exit Sub
End If
&34;C&34;C&39;处理
Dim i
Dim addcount As Long
With ThisWorkbook.Worksheets(&34;)
.Columns(1).ClearContents
.Columns(2).ClearContents
For i = startrow To stoprow Step 2
addcount = addcount + 1
.Cells(addcount, 1) = ThisWorkbook.Worksheets(&34;).Cells(i, 1)
.Cells(addcount, 2) = ThisWorkbook.Worksheets(&34;).Cells(i + 1, 1)
Next i
.Activate
End With
End Sub
温馨提示:通过以上关于实例41 拆分中文英文数字,42 两列交叉合并,43 一列交叉拆分为两列内容介绍后,相信大家有新的了解,更希望可以对你有所帮助。