ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Coding (https://www.excelbanter.com/excel-programming/278738-macro-coding.html)

JulieB[_2_]

Macro Coding
 
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

Ron de Bruin

Macro Coding
 
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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"JulieB" wrote in message ...
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





All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com