View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro Magic Wand

Nigel...

I'm a sniff away from from making you code work for me.
The problem that I have is that the code cycles through
fine but doesn't locate the value that I asked it to
despite being case sensitive. Could the problem be that
my values are text strings?

For example I need to locate the value London...I enter
this into the input box but returns that no rows have
been deleted (so therefore no London (s) found.

What am I doing wrong..?

Thanks for your help buddy...

GOrdon


-----Original Message-----
Try this.... it give you the count of removed rows at

the end.

Public Sub remove()
Worksheets("Sheet1").Activate
Dim lastrow As Long
Dim lastcol As Long
Dim sString As String
sString = InputBox("Delete Row(s) were cell has this

value.")
lastrow = ActiveSheet.UsedRange.Rows.Count
lastcol = ActiveSheet.UsedRange.Columns.Count
Application.ScreenUpdating = False
Dim ir As Long, ic As Long, rd As Long
For ir = lastrow To 1 Step -1
For ic = lastcol To 1 Step -1
If Cells(ir, ic).Value = sString Then
Rows(ir).Delete shift:=xlUp
rd = rd + 1
End If
Next ic
Next ir
Application.ScreenUpdating = True
MsgBox "Deleted: " & rd & " rows"
End Sub

Cheers
Nigel

"Gordon" wrote in

message
...
Hi guys...

Each monday I get a spreadsheet that's 10,00 lines deep
and 100 across. My task is to locate certain values
within any cell within that sheet and then delete the

row
in which the value was found. Typically I have about

300
values to find and it takles me around 4 hours - I've
reached breaking point!

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)

Are there any examples of this type of functional
programming around...can anyone help me do this? Is it
possible, can Excel VBA handle this?

Thanks in advance

Gordon.



.