Sub 宏宏宏宏宏宏宏1() For x = 2 To ActiveSheet.UsedRange.Rows.Count - 2 Step 1 If Cells(x, 1) <> Cells(x + 1, 1) And Cells(x + 1, 1) = "" Then Cells(x + 1, 1).Value = Cells(x, 1) End If Next End Sub
Cells(x, 1)代表2行1列,改成对应你的户编号列数字就可以了
Sub 宏宏宏宏宏宏宏1() For x = 2 To ActiveSheet.UsedRange.Rows.Count - 2 Step 1 If Cells(x, 1) <> Cells(x + 1, 1) And Cells(x + 1, 1) = "" Then Cells(x + 1, 1).Value = Cells(x, 1) End If Next End Sub
原文:https://www.cnblogs.com/luohaolqitfk/p/8513783.html