答案 0 :(得分:0)
假设工作表的设置与您发布的图像完全相同,这应该可以工作。
Sub combine_rows()
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("B5:B" & lastrow)
End With
Count = lastrow + 1
For Each cell In rng
If Len(cell.Value) > 0 Then
ActiveSheet.Range("A" & Count).Value = cell.Value
cell.Value = ""
ActiveSheet.Range("C" & Count) = cell.Offset(0, 1).Value
Count = Count + 1
End If
Next
End Sub