PDA

View Full Version : Excel Help


gpick24
12-07-2010, 01:43 PM
Hi all,
I need to delete the entire row on a worksheet where the cell in column A contains any of two phrases.
I`ve googled this and it looks like it has to be done with VBA. I`ve seen several examples but don`t have clue how to edit these to work on my worksheet.
Any ideas.
If you need to know, the phrases are "view financials" and "credit report available"
Thanks,
gpick.

ken
12-08-2010, 12:28 PM
You don't say whether or not there are any empty cells before the end of the list in column "A".
If all consecutive cells in column "A" are occupied then copy/paste the code below into a module then run macro "DeleteRows".

This macro will run until an empty cell in column "A" is reached.
Sub DeleteRows()
'
' MacroDeleteRows Macro
'
' Keyboard Shortcut: Ctrl+i
'This will select cell A1
Range("A1").Select

'This will run the code until an empty cell in column A is reached
Do While ActiveCell.Value <> Empty
If ActiveCell = "credit report available" Or ActiveCell = "view financials" Then
ActiveCell.EntireRow.Select
Selection.Delete
Else
ActiveCell.Offset(1).Range("A1").Select
End If
Loop
End SubHTH.

edit:
I forgot to delete the line of comment about the keyboard short-cut, if you want to use a keyboard short-cut open the macro selection box (Developer tab), select the macro named "DeleteRows" then click options and insert a keyboard short-cut.

gpick24
12-09-2010, 04:20 AM
Thanks a million Ken, works like a charm.
Gpick.

ken
12-09-2010, 04:40 AM
You're welcome :tup: