MrExcel Message Board
enter>


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Feb 9th, 2004, 09:45 PM   #1
wwbwb
 
wwbwb's Avatar
 
Join Date: Oct 2003
Location: Colorado
Posts: 312
Default deleting row macro not working like it should?

On sheet1 a1 I have a formula that pulls data from a different sheet. The formula is ='Web data'!d1. This is filled down to a400. The information that is on the Web data sheet is brought in by a query. When I refresh the query, the data that I need is not always in the same row, but IS always in the same column. What I was hoping to do was, copy the column from the query page, then run the macro to delete all the rows that have a 0 in them. In theory, this was supposed to delete all the rows with 0 and leave the 42 rows of data, the rows without 0. But what happens is it deletes evey other row. And it hangs up and I get an error msg when it hits row 256. What am I doing wrong?

Code:
Sub delete()
Application.ScreenUpdating = False
For n = 1 To 400
With Worksheets("Sheet1")
If .Cells(1, n) = "0" Then .Rows(n).delete
End With
Next n
Application.ScreenUpdating = True
End Sub
wwbwb is offline   Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 04:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.