|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
学习拆分合并的单元格,修改其中一行代码运行后错误。将原代码 .Range(.Cells(i, 2), .Cells(i + IntCot - 1, 2)).Value改为.Range(.Cells(i+1, 2), .Cells(i + IntCot - 1, 2)).Value结果就错了,按照理解,拆分后单元格区域range("A1:A3").value=range("A1")与ange("A2:A3").value=range("A1")应该是一样的。正确的原代码如下:
Sub unmerge1()
Dim strmer As String
Dim intcot As Integer
Dim introw As Integer
Dim i As Integer
With Sheet1
For i = 1 To .Range("A1000000").End(xlUp).Row
strmer = .Cells(i, 1).Value
intcot = .Cells(i, 1).MergeArea.Count
.Cells(i, 1).unmerge
.Range(Cells(i, 1), Cells(i + intcot - 1, 1)).Value = strmer
i = i + incot
Next
End With
End Sub
|
|