Macro Coding

J

JulieB

I am needing some help on a coding issue in an Excel
Macro. I want the macro look for a value in a cell and
when it finds that value, I want it to delete that row.
Is this possible?

Also, are there any tips out there on how to code the
macro to start looking from the bottom up, instead of the
top down? I want to try to incorporate the macro to Auto
fill, but my data varies each time I import information.
If I auto fill the way I have it now, it will not auto
fill if I have more records.

Any help would be appreciated. Thanks and have a great
weekend!-----Julie
 
R

Ron de Bruin

Hi Julie

Example for column A

Sub DeleteRows()
findstring = "ron"
Set b = Range("A:A").find(What:=findstring, LookAt:=xlWhole)
While Not (b Is Nothing)
b.EntireRow.Delete
Set b = Range("A:A").find(What:=findstring, LookAt:=xlWhole)
Wend
End Sub

Example for looking from the bottom to the top

Dim a As Long
Dim i As Long
i = Cells(Rows.Count, "A").End(xlUp).Row
For a = i To 1 Step -1
If Cells(a, "A").Value = "ron" Then
Cells(a, "A").EntireRow.Delete
End If
Next a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top