我想在删除刚从中复制信息的行后,将活动单元格选择向上移动1行。错误发生在第19行:
Dim row As Integer, col As Integer, MyRow As Integer, MyCol As Integer
Dim str1 As String, str2 As String
row = 2
col = 5
MyRow = ActiveCell.row
MyCol = ActiveCell.Column
Sheets("Sheet1").Activate
Sheets("Sheet1").Range("E2").Select
Set curCell = Sheets("Sheet1").Cells(row, col)
Do Until IsEmpty(ActiveCell)
If ActiveCell = Cells(ActiveCell.row + 1, ActiveCell.Column) Then
For col = 1 To 15
Cells(ActiveCell.row, col) = Cells(ActiveCell.row, col) & " | " & Cells(ActiveCell.row + 1 + 1, col)
Next col
ActiveCell.Offset(1, 0).Select
Rows(ActiveCell.row).EntireRow.Delete
End If
ActiveCell.Offset(-1, 0).Select
Loop
我认为ActiveCell.Offset(-1, 0).Select
会使选择上升1行。这不是怎么做的?感谢
答案 0 :(得分:1)
活动单元格从 E2 开始,然后移至 E1 。如果 E1 不为空,则代码会尝试移至 E0 ,这会产生错误。