Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 17
Default automating delection of certain rows

I am trying to automate through a Macro the operation
where all rows in a worksheet with a value of 0 (zero)
will be deleted. how may I accomplish this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default automating delection of certain rows

Hi Sam;

This code assumes that every cell starting in cell A1 and
going down has something in it for every line and then
deletes the row if you want to check the cells in column D

Sub DeleteTheZeros()
Range("A1").Select
While Not ActiveCell = ""


'checks for the zero value 3 columns to the right
of column A
If ActiveCell.Offset(0, 3) = 0 Then
Application.DisplayAlerts = False
ActiveCell.EntireRow.Delete
End If

ActiveCell.Offset(1, 0).Select
Wend
End Sub

Thanks,

Greg
-----Original Message-----
I am trying to automate through a Macro the operation
where all rows in a worksheet with a value of 0 (zero)
will be deleted. how may I accomplish this?
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default automating delection of certain rows

Select a single set of cells, 1 column wide. then run this macro.

Sub DeleteRows()
Dim i as Long
for i = selection.rows(selection.rows.count).row to selection.Row step -1
if cells(i,Selection.Column).Value = 0 and
Trim(Cells(i,Selection.Column).Value) < "" then
cells(i.Selection.Column).Entirerow.Delete
end if
Next
End Sub
--
Regards,
Tom Ogilvy

"sam" wrote in message
...
I am trying to automate through a Macro the operation
where all rows in a worksheet with a value of 0 (zero)
will be deleted. how may I accomplish this?



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default automating delection of certain rows

Thank you for your help. When I try to run this Macro, I
get an error message. End If is highlighted and the error
message box reads: End If Without Block If

how may I fix this?

sam

-----Original Message-----
Hi Sam;

This code assumes that every cell starting in cell A1 and
going down has something in it for every line and then
deletes the row if you want to check the cells in column D

Sub DeleteTheZeros()
Range("A1").Select
While Not ActiveCell = ""


'checks for the zero value 3 columns to the right
of column A
If ActiveCell.Offset(0, 3) = 0 Then
Application.DisplayAlerts = False
ActiveCell.EntireRow.Delete
End If

ActiveCell.Offset(1, 0).Select
Wend
End Sub

Thanks,

Greg
-----Original Message-----
I am trying to automate through a Macro the operation
where all rows in a worksheet with a value of 0 (zero)
will be deleted. how may I accomplish this?
.

.

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default automating delection of certain rows

Sub DeleteTheZeros()
Range("I2").Select
While Not ActiveCell = ""

If ActiveCell = 0 Then
Application.DisplayAlerts = False
ActiveCell.EntireRow.Delete
else
ActiveCell.Offset(1, 0).Select
End if
Wend
End Sub


--

Regards,
Tom Ogilvy





wrote in message
...
Thank you for your help. When I try to run this Macro, I
get an error message. End If is highlighted and the error
message box reads: End If Without Block If

how may I fix this?

sam

-----Original Message-----
Hi Sam;

This code assumes that every cell starting in cell A1 and
going down has something in it for every line and then
deletes the row if you want to check the cells in column D

Sub DeleteTheZeros()
Range("A1").Select
While Not ActiveCell = ""


'checks for the zero value 3 columns to the right
of column A
If ActiveCell.Offset(0, 3) = 0 Then
Application.DisplayAlerts = False
ActiveCell.EntireRow.Delete
End If

ActiveCell.Offset(1, 0).Select
Wend
End Sub

Thanks,

Greg
-----Original Message-----
I am trying to automate through a Macro the operation
where all rows in a worksheet with a value of 0 (zero)
will be deleted. how may I accomplish this?
.

.



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
Automating skipping rows between selected cells. Please Help binar[_2_] Excel Discussion (Misc queries) 3 February 4th 09 02:05 AM
Automating deleting rows Alice Excel Discussion (Misc queries) 2 March 10th 08 06:35 PM
Automating Excel mvpejp Excel Discussion (Misc queries) 0 November 22nd 05 07:33 PM
Automating using VBA Automate my database Excel Worksheet Functions 1 September 1st 05 01:51 PM
Automating PP from XL Keith R[_3_] Excel Programming 0 November 20th 03 08:42 PM


All times are GMT +1. The time now is 02: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"