最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

【實(shí)例13-分割數(shù)據(jù)至多個(gè)單元格】【實(shí)例14-合并多個(gè)單元格數(shù)據(jù)】Excel表格VBA編程實(shí)例

2023-02-27 00:56 作者:凌霄百科_Excel辦公程序  | 我要投稿

實(shí)例13-分割數(shù)據(jù)至多個(gè)單元格

Private Sub CommandButton分割數(shù)據(jù)_Click()

'分割符號(hào)不能為空

With ThisWorkbook.Worksheets("操作界面")

Dim splittext As String

If .Cells(5, "C").Value <> "" Then

splittext = .Cells(5, "C").Value

Else

MsgBox "請輸入分割符號(hào)"

Exit Sub

End If

'處理內(nèi)容不能為空

Dim splitcontent As String

If .Cells(8, "B").Value <> "" Then

splitcontent = .Cells(8, "B").Value

Else

MsgBox "請輸入處理內(nèi)容"

Exit Sub

End If

End With

'清除處理結(jié)果

With ThisWorkbook.Worksheets("處理結(jié)果")

.Columns(1).ClearFormats

.Columns(1).ClearContents

'分割數(shù)據(jù)

Dim split_array

split_array = Split(splitcontent, splittext)

Dim i

For i = 0 To UBound(split_array)

.Cells(i + 1, 1).Value = split_array(i)

Next i

.Activate

End With

End Sub

實(shí)例14-合并多個(gè)單元格數(shù)據(jù)

Private Sub CommandButton合并數(shù)據(jù)_Click()

'合并符號(hào)不能為空

With ThisWorkbook.Worksheets("操作界面")

Dim mergetext As String

If .Cells(4, "C").Value <> "" Then

mergetext = .Cells(4, "C").Value

Else

MsgBox "請輸入合并符號(hào)"

Exit Sub

End If

'合并區(qū)域不能為空

Dim mergerange As String

If .Cells(7, "C").Value <> "" Then

mergerange = .Cells(7, "C").Value

Else

MsgBox "請輸入合并區(qū)域地址"

Exit Sub

End If

'清除原結(jié)果區(qū)域

.Cells(10, "B").Value = ""

'合并數(shù)據(jù)

Dim itemcell

Dim mergeresult As String

For Each itemcell In ThisWorkbook.Worksheets("待合并數(shù)據(jù)").Range(mergerange)

If itemcell.Value <> "" Then

If mergeresult <> "" Then

mergeresult = mergeresult & mergetext & itemcell.Value

Else

mergeresult = itemcell.Value

End If

End If

Next

.Cells(10, "B").Value = mergeresult

End With

End Sub


【實(shí)例13-分割數(shù)據(jù)至多個(gè)單元格】【實(shí)例14-合并多個(gè)單元格數(shù)據(jù)】Excel表格VBA編程實(shí)例的評(píng)論 (共 條)

分享到微博請遵守國家法律
穆棱市| 兴文县| 昌邑市| 阿拉善左旗| 应城市| 济南市| 汾阳市| 思南县| 广宁县| 永修县| 桦南县| 中山市| 砀山县| 洪洞县| 南通市| 额济纳旗| 漳州市| 河曲县| 吉林省| 汶上县| 陈巴尔虎旗| 桂林市| 扎赉特旗| 林甸县| 枣强县| 乌海市| 临海市| 秦安县| 汝南县| 霍城县| 绩溪县| 贡嘎县| 辽阳县| 磐石市| 房山区| 新龙县| 郎溪县| 砚山县| 五大连池市| 柘城县| 湄潭县|