0
我有以下代碼,需要刪除列A中包含信息的數據行。這些行是「標題」和「頁腳」信息,它們傾向於訪問我需要的數據。刪除包含數據的行
我認爲我有一個解決方案設置如下,但它似乎並沒有工作在A列中刪除相應的行
編號:
Sub CleanUpFB()
Dim Sheet4 As Worksheet
Dim delRng As Range
Dim LastRow As Integer, LastRow2 As Integer
Dim i As Integer
Set Sheet4 = Excel.Worksheets("FB Product")
LastRow = Range("D3").End(xlDown).Row
'Re-align Revision Column.
Range("D3:D" & LastRow).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlToLeft
'Delete First Row
Sheet4.Rows(1).Delete
'Delete Rows in Column A that contain words.
LastRow2 = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow2
If InStr(1, Cells(i, 1).Value, "*", vbTextCompare) Then
If delRng Is Nothing Then
Set delRng = Rows(i)
Else
Set delRng = Union(delRng, Rows(i))
End If
End If
Next i
If Not delRng Is Nothing Then delRng.Delete
End Sub
單:
'Range(「B1」)。End(xlUp).Row'將始終爲1.您的意思是'xlDown'? –
我的意思是'xlDown'並將其更改爲'Range(「A」&Rows.Count).End(xlUp).Row',但我仍然遇到刪除列A中顯示的字符串的問題...... _I已將我的代碼修改爲我正在嘗試執行的操作_ –