全解vba初学者编程代码大全 vba编程代码大全( 三 )


文章插图
Sub hebing()
a = “”
For i = 1 To Range(“A65536”).End(xlUp).Row + 1
If Cells(i, 1) = “” Then
Range(“C” & i + 1 & “:C” & Range(“A” & i + 1).End(xlDown).Row).Merge
Cells(Range(“A” & i – 1).End(xlUp).Row, 3) = a
a = “”
Else
If a = “” Then
a = Cells(i, 1)
Else
a = a & Cells(i, 1)
End If
End If
Next
End Sub