justanotheruser
Board Regular
- Joined
- Aug 14, 2010
- Messages
- 96
Hi guys,
I've created this macro that will search down the rows in a sheet and delete all rows from A2 downwards if it has a "#" in Column A. However, each time it is run, it is looking down 10,000 rows - so it is taking a very long time to run!
Is there any way to make this work faster? One idea I had was to find all the rows that don't have a # in Column A (a "#" will be the only value of the cell if the row is to be deleted) and copy and paste those into a new sheet - is this possible, as I'd imagine it'd be a lot faster?
Thanks in advance for your help!
I've created this macro that will search down the rows in a sheet and delete all rows from A2 downwards if it has a "#" in Column A. However, each time it is run, it is looking down 10,000 rows - so it is taking a very long time to run!
Code:
Sub DeleteRowWithContents1()
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "#"IN COLUMN A
'========================================================================
Last = Cells(Rows.Count, "A").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "A").Value) = "#" Then
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
Is there any way to make this work faster? One idea I had was to find all the rows that don't have a # in Column A (a "#" will be the only value of the cell if the row is to be deleted) and copy and paste those into a new sheet - is this possible, as I'd imagine it'd be a lot faster?
Excel Workbook | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | scenario_code | company_code | account_code | ||
2 | # | # | # | ||
3 | # | # | # | ||
4 | # | # | # | ||
5 | # | # | # | ||
6 | # | # | # | ||
7 | # | # | # | ||
8 | # | # | # | ||
9 | # | # | # | ||
10 | # | # | # | ||
11 | # | # | # | ||
12 | 2011_ACT | SSGUK | 100100 | ||
13 | 2011_ACT | SSGUK | 100100 | ||
14 | 2011_ACT | SSGUK | 100100 | ||
15 | 2011_ACT | SSGUK | 100100 | ||
16 | 2011_ACT | SSGUK | 100100 | ||
17 | # | # | # | ||
18 | # | # | # | ||
19 | # | # | # | ||
ETL ICO |
Thanks in advance for your help!