Sub 合并列() Dim hang As Integer '控制输出的行 Dim lie As Integer '控制输出的列 hang = Selection.Cells(1).Row lie = Selection.Columns.Count + Selection.Cells(1).Column '默认在选定区域后的第一列输出 Dim sHang As Integer '选定区域的左上第一个单元格的行下标 Dim sLie As Integer '选定区域的左上第一个单元格的列下标 For sLie = Selection.Cells(1).Column To Selection.Columns.Count + Selection.Cells(1).Column - 1 '列后循环 Selection.Columns.Count 为选定区域的列数 For sHang = Selection.Cells(1).Row To Selection.Rows.Count + Selection.Cells(1).Row - 1 '行先循环 If Cells(sHang, sLie) = "" Then '若当前单元格内容为空则跳出当前循环 Exit For End If Cells(hang, lie) = Cells(sHang, sLie) '若不为空则在输出单元格输出数据 hang = hang + 1 '输出行标加1 Next Next End Sub