View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Macro Magic Wand

Ideally I'd like to click on a macro button that will
launch an input box that will allow me to for example
enter the name Jones. When I click OK on the input box I
want a macro to run through the entire sheet locating
every occourance Jones and deleting every row in which
the value Jones appear (lifting cells upwards of course)


Sub DeleteRows()
Dim rng As Range
Dim c As Range
Dim str1 As String

str1 = InputBox("Delete rows with this value.")
Set rng = Sheets("Sheet1").UsedRange
For Each c In rng
If c = str1 Then Sheets("Sheet1").Rows(c.Row).Delete
Next c
End Sub

HTH,
Merjet