Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Conditional row delete using macr

The macro below deletes alternate rows instead of all rows with Zero. I do not
know VBA. What is wrong.

Application.Goto Reference:="col"
For Each cell_in_loop In Range("col")
If cell_in_loop.Value=0 Then With cell_in_loop.EntireRow.Delete
End With
End If
Next
ActiveWorkbook.SaveAs Filename:=C\Data\Sales.............
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional row delete using macr


This is not going to work because you are deleting one row and then th
loop goes onto the next one (when it should stay at the same row an
question it again).

More appropriate might be (substitute "A" with the column that has th
values in):
dim y as long
dim x as long
y = range("A65536").end(xlup).row
x = 1
while x < y +1
If range("A" & x).Value=0 Then With range("A" & x).EntireRow.Delete
End With
y = y - 1
else
x = x + 1
End If
wend
ActiveWorkbook.SaveAs Filename:=C\Data\Sales.............

This should work

--
daveric
-----------------------------------------------------------------------
daverico's Profile: http://www.excelforum.com/member.php...fo&userid=1566
View this thread: http://www.excelforum.com/showthread.php?threadid=27199

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Conditional row delete using macr

Hi
you have to work from the bottom up to the top.

"Robert" wrote:

The macro below deletes alternate rows instead of all rows with Zero. I do not
know VBA. What is wrong.

Application.Goto Reference:="col"
For Each cell_in_loop In Range("col")
If cell_in_loop.Value=0 Then With cell_in_loop.EntireRow.Delete
End With
End If
Next
ActiveWorkbook.SaveAs Filename:=C\Data\Sales.............

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
Display "Last updated date" for the Workbook (without using a macr CRayF Excel Worksheet Functions 3 October 28th 09 08:55 PM
how to move data from a cell to another one without using any macr Mojtaba Ghassemi[_2_] Excel Worksheet Functions 2 March 9th 08 12:07 PM
Copy data from one worksheet to another using a function or a macr Sweetetc Excel Worksheet Functions 0 April 3rd 06 08:21 PM
How do I convince the cursor to select a given cell when in a macr Wulliam Excel Discussion (Misc queries) 1 November 28th 05 07:24 PM
Insert row with macr Jeroen Excel Programming 1 January 6th 04 01:13 PM


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