迈克试一试
子 appendValues()
'sub 被设计为循环遍历代码,当有空值和列 a 时,它将获取 B 列中的值并附加到它上面的行并删除该行。
将行暗淡为整数
行 = 1
'此代码从第一行开始,但可以随意更改。
直到 ThisWorkbook.Sheets("sheet1").Cells(row, 2).Value = ""
'loop语句被设计为继续循环直到你里面有一个空值第二列的值。
If ThisWorkbook.Sheets("sheet1").Cells(row, 1).Value = "" Then
ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value = ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value & ThisWorkbook.Sheets("sheet1" ).Cells(row, 2).Value
行(行)。删除
其他
'else 语句是必需的,因为通过减少删除后的总行数存在隐含循环。
行 = 行 + 1
如果结束
循环
结束子
Sub appendValues()
'The sub is designed to loop through code and when ever there is a null value and column a it will take the value of what is in column B and appended to the row above it and delete the row.
Dim row As Integer
row = 1
'This code starts with row one but this can be changed at will.
Do Until ThisWorkbook.Sheets("sheet1").Cells(row, 2).Value = ""
'loop statement is designed to continue to Loop until there is a null value inside of you the value in the second column.
If ThisWorkbook.Sheets("sheet1").Cells(row, 1).Value = "" Then
ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value = ThisWorkbook.Sheets("sheet1").Cells(row - 1, 2).Value & ThisWorkbook.Sheets("sheet1").Cells(row, 2).Value
Rows(row).Delete
Else
'else statement is needed because there is an implied looping by decreasing the total number of rows after the delete.
row = row + 1
End If
Loop
End Sub