试试这个:
Sub Demo()
Dim rng As Range
Dim lastRow As Long
Dim cell as Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A1:A" & lastrow)
For Each cell In rng
If cell.Value = "" Then
cell.Value = cell.Offset(0, 1).Value
End If
Next cell
End Sub
Sub main()
With ActiveSheet.UsedRange.Columns("A")
If WorksheetFunction.CountBlank(.Cells) > 0 Then
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=RC[1]"
.Value = .Value
End If
End With
End Sub
Sub movecells()
Dim usedrows As Integer
Dim tmpval As String
Dim i As Integer
usedrows = UsedRange.Rows.Count
For i = 1 To usedrows Step 1
If Cells(i, 1).Value = "" And Cells(i, 2).Value <> "" Then
Cells(i, 1).Value = Cells(i, 2).Value
Cells(i, 2).Value = ""
End If
Next i
End Sub