#1   Report Post  
ianalexh
 
Posts: n/a
Default code to delete rows

this is probably very simple but i am new to writing code (excel 2000).

i want to scan cells M9:M999, and for every cell where the value is 0 i want
that row deleted. so for instance M9's value is 453 and row 9 will stay, but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Do a filter (DataFilterAutofilter) and select a value of 0. Delete the
visible rows.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
this is probably very simple but i am new to writing code (excel 2000).

i want to scan cells M9:M999, and for every cell where the value is 0 i

want
that row deleted. so for instance M9's value is 453 and row 9 will stay,

but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh



  #3   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Try this example

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 9
EndRow = 999
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "M").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "M").Value = 0 Then .Rows(Lrow).Delete
'This will delete each row with the Value 0 in Column M.

End If
Next
End With

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"ianalexh" wrote in message ...
this is probably very simple but i am new to writing code (excel 2000).

i want to scan cells M9:M999, and for every cell where the value is 0 i want
that row deleted. so for instance M9's value is 453 and row 9 will stay, but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh



  #4   Report Post  
ianalexh
 
Posts: n/a
Default

i'm sorry; i wasn't specific. i want to set a macro to accomplish this, so
not-so-savvy computer users can click a button and the job gets done.

ianalexh


"Bob Phillips" wrote:

Do a filter (DataFilterAutofilter) and select a value of 0. Delete the
visible rows.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
this is probably very simple but i am new to writing code (excel 2000).

i want to scan cells M9:M999, and for every cell where the value is 0 i

want
that row deleted. so for instance M9's value is 453 and row 9 will stay,

but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh




  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Follow the steps I gave and record a macro while doing it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
i'm sorry; i wasn't specific. i want to set a macro to accomplish this,

so
not-so-savvy computer users can click a button and the job gets done.

ianalexh


"Bob Phillips" wrote:

Do a filter (DataFilterAutofilter) and select a value of 0. Delete the
visible rows.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
this is probably very simple but i am new to writing code (excel

2000).

i want to scan cells M9:M999, and for every cell where the value is 0

i
want
that row deleted. so for instance M9's value is 453 and row 9 will

stay,
but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh








  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Not quite as easy as I suggested, so here is some code

Sub DeleteZeroes()
Dim rng As Range
Set rng = Range("M8:M999")
rng.Cells(1, 1).EntireRow.Insert
rng.AutoFilter Field:=1, Criteria1:="=0"
rng.SpecialCells(xlCellTypeVisible).EntireRow.Dele te
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Phillips" wrote in message
...
Follow the steps I gave and record a macro while doing it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
i'm sorry; i wasn't specific. i want to set a macro to accomplish this,

so
not-so-savvy computer users can click a button and the job gets done.

ianalexh


"Bob Phillips" wrote:

Do a filter (DataFilterAutofilter) and select a value of 0. Delete

the
visible rows.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"ianalexh" wrote in message
...
this is probably very simple but i am new to writing code (excel

2000).

i want to scan cells M9:M999, and for every cell where the value is

0
i
want
that row deleted. so for instance M9's value is 453 and row 9 will

stay,
but
M10's value is 0 so row 10 is deleted. so on and so forth.

thanks so much!
ianalexh







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete blank rows John Mansfield Excel Discussion (Misc queries) 3 April 27th 05 11:48 PM
How can I delete rows from Pivot Tables in Excel 2000 as in 97 Rex at B$4U Excel Discussion (Misc queries) 0 April 18th 05 04:55 AM
Delete specified critria rows rn Excel Discussion (Misc queries) 4 March 21st 05 12:51 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
delete repeating rows aledger Excel Worksheet Functions 2 March 4th 05 08:43 PM


All times are GMT +1. The time now is 09:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"