Hi
I've got two quick questions.
I've got some code which deletes entire rows, if a word is present in column A (see below).
1) Do you know how I can modify the code to delete a range of cells ie A5:AC100000 instead of deleting the entire row where it finds the word specified?
2) How can I amend the code below so it refers to cell B4 in a file that I'm importing? The file being imported is declared as a workbook (Dim importWB As Workbook) and is set using "Set importWB = ActiveWorkbook" whenever it's referred to. If you'd like the long version of the code, please let me know.
Thanks in advance.
Sub DeleteRows()
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORD "Coffee" IN COLUMN A
'========================================================================
Last = Cells(Rows.Count, "A").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "A").Value) = "0032-0007 - Coffee" Then
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
I've got two quick questions.
I've got some code which deletes entire rows, if a word is present in column A (see below).
1) Do you know how I can modify the code to delete a range of cells ie A5:AC100000 instead of deleting the entire row where it finds the word specified?
2) How can I amend the code below so it refers to cell B4 in a file that I'm importing? The file being imported is declared as a workbook (Dim importWB As Workbook) and is set using "Set importWB = ActiveWorkbook" whenever it's referred to. If you'd like the long version of the code, please let me know.
Thanks in advance.
Sub DeleteRows()
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORD "Coffee" IN COLUMN A
'========================================================================
Last = Cells(Rows.Count, "A").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "A").Value) = "0032-0007 - Coffee" Then
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub