2
我想寫的是通過一組利率有3列的循環宏偏移: rate_table,rate_date,速度刪除行1
這裏是我到目前爲止所。我想我只需要命令來刪除行
Private Const RATE_TABLE_COL = 1
Private Const RATE_DATE_COL = 2
Private Const RATE_COL = 3
Sub RemoveDuplicateRates()
Dim iLastRow As Long, iRow As Long, sThisRate As String, sPrevRate As String
'Find the last row (in column A) with data.
iLastRow = shtSource.Range("A:A").Find("*", searchdirection:=xlPrevious).Row
If iLastRow < 2 Then
MsgBox "No data to process!", vbCritical
Exit Sub
End If
sThisRate = ""
sPrevRate = ""
For iRow = iLastRow To 1 Step -1
sPrevRate = sThisRate
sThisRate = Cells(iRow, 1)
If sThisRate = sPrevRate Then
If Cells(iRow, RATE_COL) = Cells(iRow - 1, RATE_COL) Then
' need code here to delete row offset by 1 from iRow
End If
End If
Next iRow
End Sub
像'範圍()偏移(1,0).EntireRow.Delete' – CallumDA
'細胞(iRow + 1,RATE_COL).entirerow.delete' ??? – SJR
因爲iRow-1 = 0,所以你的代碼會在你的循環結束時出錯。 – SJR