deleting blank rows for up to 60000 rows of data

I have worksheets with up to 60000 rows in one column I have tried using the 
following macro from this site and it does not do anything. Any ideas?:

Sub Sonic()
Dim i As Long
With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    Lastrow = ActiveSheet.UsedRange.Rows.Count
    For i = Lastrow To 1 Step -1
        If WorksheetFunction.CountA(Rows(i)) = 0 Then
            Rows(i).EntireRow.Delete
        End If
    Next i
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub

0
Utf
12/27/2009 8:26:01 AM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
1009 Views

Similar Articles

[PageSpeed] 31

Hi,

The code works fine for me. One point is the entire row must be empy before 
it will be selected for deletion. i.e a formula thta returns a null string 
and looks empty won't be deleted.

Sub Sonic()
Dim i As Long
With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    Lastrow = ActiveSheet.UsedRange.Rows.Count
    For i = Lastrow To 1 Step -1
        If WorksheetFunction.CountA(Rows(i)) = 0 Then
            Rows(i).EntireRow.Delete
        End If
    Next i
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub

Mike

"gbpg" wrote:

> I have worksheets with up to 60000 rows in one column I have tried using the 
> following macro from this site and it does not do anything. Any ideas?:
> 
> Sub Sonic()
> Dim i As Long
> With Application
>     .Calculation = xlCalculationManual
>     .ScreenUpdating = False
>     Lastrow = ActiveSheet.UsedRange.Rows.Count
>     For i = Lastrow To 1 Step -1
>         If WorksheetFunction.CountA(Rows(i)) = 0 Then
>             Rows(i).EntireRow.Delete
>         End If
>     Next i
>         .Calculation = xlCalculationAutomatic
>         .ScreenUpdating = True
>     End With
> End Sub
> 
0
Utf
12/27/2009 9:15:02 AM
Noe,

I hope this is work for you 
Sub Delete_Rows()
Range("C1").Select
 


      a = 0

 

Do While a <> 1

    If ActiveCell.Value = Empty Then
    Selection.EntireRow.Delete
    Else

  
   

    End If

    

    If ActiveCell.Value = "BLANK" Then

        a = 1

    Else

        ActiveCell.Offset(1, 0).Activate

  

    End If

Loop
Application.CutCopyMode = False
Range("A2").Select

End Sub




"gbpg" wrote:

> I have worksheets with up to 60000 rows in one column I have tried using the 
> following macro from this site and it does not do anything. Any ideas?:
> 
> Sub Sonic()
> Dim i As Long
> With Application
>     .Calculation = xlCalculationManual
>     .ScreenUpdating = False
>     Lastrow = ActiveSheet.UsedRange.Rows.Count
>     For i = Lastrow To 1 Step -1
>         If WorksheetFunction.CountA(Rows(i)) = 0 Then
>             Rows(i).EntireRow.Delete
>         End If
>     Next i
>         .Calculation = xlCalculationAutomatic
>         .ScreenUpdating = True
>     End With
> End Sub
> 
0
Utf
12/27/2009 5:18:01 PM
Delting Rows one at a time is extremely slow.  Why don't you sort the
rows and the blank cells will simply move to the bottom.  To get the
data back to the original postion add an inedx column like the code
below

the code may seem a lot but it will run in seconds instead of the other
posted code taking minutes.

Sub SortBlanks()

LastRow = Range("A" & Rows.Count).End(xlUp).Row
'add count 1, 2 to column IV
Range("IV1:IV" & LastRow).Formula = "=Row()"
'change formula to value
Range("IV1:IV" & LastRow).Copy
Range("IV1:IV" & LastRow).PasteSpecial _
Paste:=xlPasteValues

'sort using column A
Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=Range("A1"), _
order1:=xlAscending

'now find new Last row
LastRow = Range("A" & Rows.Count).End(xlUp).Row
'sort using column IV
Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=Range("IV1"), _
order1:=xlAscending

'delete column IV
Columns("IV").Delete

End Sub


-- 
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=165245

[url=&quot;http://www.thecodecage.com&quot;]Microsoft Office Help[/url]

0
joel
12/27/2009 8:24:38 PM
Hi

Try this one liner, just change the column letter to suit:

Sub DeleteEmptyRows()
    Columns("B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

Regards,
Per

On 27 Dec., 09:26, gbpg <g...@discussions.microsoft.com> wrote:
> I have worksheets with up to 60000 rows in one column I have tried using =
the
> following macro from this site and it does not do anything. Any ideas?:
>
> Sub Sonic()
> Dim i As Long
> With Application
> =A0 =A0 .Calculation =3D xlCalculationManual
> =A0 =A0 .ScreenUpdating =3D False
> =A0 =A0 Lastrow =3D ActiveSheet.UsedRange.Rows.Count
> =A0 =A0 For i =3D Lastrow To 1 Step -1
> =A0 =A0 =A0 =A0 If WorksheetFunction.CountA(Rows(i)) =3D 0 Then
> =A0 =A0 =A0 =A0 =A0 =A0 Rows(i).EntireRow.Delete
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 Next i
> =A0 =A0 =A0 =A0 .Calculation =3D xlCalculationAutomatic
> =A0 =A0 =A0 =A0 .ScreenUpdating =3D True
> =A0 =A0 End With
> End Sub

0
Per
12/27/2009 8:37:35 PM
Reply:

Similar Artilces:

Pivot Table row comparison
I'm trying to compare an old customer schedule with their new schedule and highlight the changes with colour or by hiding a row. My pivot table looks like this Prod Sched wk1 wk2 wk3 A old 3 2 3 A new 3 4 3 B old 2 2 2 B new 2 2 2 So in the above example I'd like to colour the cells for wk2- Product A in yellow, and hide the product B rows as there has been no change in demand. Can someone give me some advice about how to do this Thanks for your help Ross How about an alternative??? Your raw data looks kind of like this: Prod Sched wk# qty...

How to Recover Deleted Sent Mail?
While trying to delete very old "Sent" mail I seem to have deleted all "Sent" mail. Is there a way of recovering this mail? Have you closed Outlook since deleting the old sent mail? http://www.howto-outlook.com/howto/restoredeleteditemsfromanoutlookpst.htm might help. Next time, archive the items you want removed from your active .pst file. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. After furious head scratching, Sidney Friedman as...

Cannot delete subreport
I am using Access 2003 and have a report I did a while back with a simple subreport. I want to remove the subreport but for the life of me can't figure out how to do it. Any help would be greatly appreciated. Thanks. Hi - When you say "remove the sub report", what do you mean? Do you want to delete the entire subreport control containing the subreport, or do you want to keep the control, but change the report contained in it? The first is easy - select the control by clicking once on it once, then press delete. For the second, click the control once, then set ...

Rule for Deleted Items
I am being told that there is a rule in place on my Exchange server that will not empty the deleted items folder every 30 days for certain users in my organization. I found a recipient policy in System Manager that says "Users Excluded from Mailbox Cleanup" but it only shows 2 users and not the 3 I was told about. But I have confirmed that the missing person has email in her deleted items folder going back to 2005 so it must be working. Is there any other location I should be looking? Also, we just had someone come in and migrate our Exchange environment from 2000 to a new...

keying in data in cell
I have a form that has several lines. I want to know without looking at the form when the data will not show on the line. I do not want to wrap the text, but to go to the next row to continue to put in the data. Is there an easy way to do this. Any help will be appreciated. thank you mac ...

I need to show the last number in a rows in the total pending row
I have a column where I list pending cases each month and I need to show the last number in the total pending cell at the bottom of the row. I can use an offset fomula which works if the pending cases begin in row 1. However, I am not able to get it to work if the pending cases begin in rows 4 or 5 as an example. Any suggestion? Rows don't have a bottom.............guess you meant Column. Last number in column A =LOOKUP(99^99,A:A) Last anything in column A =LOOKUP(2,1/(A1:A65535<>""),A1:A65535) Gord Dibben MS Excel MVP On Wed, 28 Jan 2009 16:30:08 -0800, Jen S ...

number of rows #2
I used autoformat so that my rows would alternate colors. But, it added a bunch of empty rows so that the sheet is maxed out and my file is huge. I don't need all those empty rows and I can't find a way to delete them. Any suggestions for how to get rid of the rows, or limit the number of rows on a worksheet? I know I could copy all the data to a new worksheet, but I'd like a better solution. Try this: click on the number of the first empty row, so the whole row is selected. Using the vertical scrollbar, go to the last row on the sheet. Hold down the shift key while you cli...

What to do to improve this:Outlook is retrieving data from the Microsoft Exchange Server server_name.
Out2002, Exch2000SP3. Users at times complain that they are getting those pop up messages Outlook is retrieving data from the Microsoft Exchange Server server_name. I just want to confirm that if I install a global catalog on the site where users are getting this, that should improve the situation right ? Is the message below generated only when the Outlook client "takes too long" to retrieve data from the GC ? Something else that could cause that behavior ? On Mon, 18 Oct 2004 10:40:57 -0700, "Marlon Brown" <marlon_brown@hotmail.com> wrote: >Out2002, Exc...

cannot delete message from deleted items
I have a message in my deleted items folder that when choosing delete opens the McAfee box warning of potential virus and wants me to choose open or do not open, but will not delete. I have tried choosing another file and holding ctrl and choosing the file I want deleted and then choosing delete, I have tried moving it to the desktop but it will only copy there, I have tried every form of delete possible. I need help. Anyone know how? Outlook 2002. Can you empty the deleted items folder entirely? Or turn off the McAfee scanning temporarily to see if it makes a difference? Julie wr...

blank GP instance
Hello: Strange question....is there anything "bad" about having a GP instance without a name? Seriously, the instance has () in Add/Remove Programs and Start...All Programs...Microsoft Dynamics shows the name of the GP folder as "GP 10.0- ". I got the Dexterity Shared Components error and used the DOS method of getting around it as outlined in a TK. The second DOS command produced an error saying that a named instance can only be created when you have an instance. Yep, it sounds like the computer was drunk or something. Nevertheless, I went along with it. I re...

I can not delete a duplicate personal folders list #2
Vall... amazing that there isn't an easy fix for this. The instructions provided simply don't work ( tools-email accounts-view change email accounts-deliver to new account-finish-close outlook and reopen ), and none of the other offered explanations have worked either. As this is such a common problem; why hasn't microsoft provided a very EASY fix? I am more confused ( and frightened ) and don't want to make the problem worse! Your profile is corrupt, probably based on an incorrect migration of your ..pst file. Create a new mail profile and configure it to use your exi...

Manipulating Pivot Table Data Fields
Hi all, Have a question regarding the Data Field in pivot tables. I have a number of rows that have repeating values. What I want in the Data Field (Sum) is a count of DISTINCT values in the column. ie: FR065817 \ FR065817 |----> counted as one FR065817 / FR066154 \___> counted as one FR066154 / FR066158 -----> counted as one FR066159 \___> counted as one FR066159 / However I need all the data in the table as I'm using other columns for different fields in the pivot table. Is there a way to do this? If I have to split the table somehow, I'm willing to do...

Question about Exch2k3 SP2 75gb data store limits
I am about to roll out Exchange 2003 SP2 in a fresh environment, and was curious about what the 75GB limits on the databases encompasses. Since Exchange 2003 Standard supports up to four databases, does this mean I can have four individual 75 GB databases running under Exchange 2003 Standard, or does it mean the total of all four databases can't exceed 75 GB, therefore requiring Exchange 2003 Enterprise? Not sure where you obtained that information from - Exchange Server 2003 Standard does not support 4 databases. You can have 2 - one Mailbox Store and one Public Folder Store. ht...

how can I export data by VBA and specify type of delimitor
I want to export data from excel by VBA and specify to use ',' as delimitor. but I can only export a file rename to .csv. but when I open it, it still a excel file, but not a text file. How can I do it? Million thanks. You could (temporarily???) change your windows list separator: Windows start button|Settings|control panel regional and language Settings Options applet. regional Options tab|customize button List separator near the bottom of the dialog. Or you could use a macro. You could borrow some code from one of these sites: Chip Pearson's: http://www.cpearson.com/excel/...

Retrieval of Deleted Items After Being Deleted from the Deleted Items File
I deleted a number of important emails from the deleted items file in Outlook 2000. This may sound stupid, but I completely emptied the deleted items file instead of deleting them one by one. Pretty stupid, huh. Anyone. Can they be retrieved? Please help. Thanks. Sorry for sending this again but I seem to be computer illiterate and it has taken me some time to explain the whole situation. Thanks again. unless you use Exchange server with deleted retention enabled, you are most likely out of luck, but you can try something that might help.... http://www.outlook-tips.net/howto/r...

Prints blank page first?
I created a publication on one computer (Pub 2000, Win98SE), burned it to a CD, and am trying to print from another computer (Publisher 2000 with Win2000 and an HP Deskjet printer). Ctrl+P, Print page 1 to 1 - and I get a blank sheet coming out first, then Page 1. Same thing happened with Page 2. Did I miss a setting somewhere? Ed Did you try copying the file to the hard drive first and then print? Open the printers and fax folder in the control panel, right-click your printer, properties, advanced tab, separator page button, clear anything it may say in the "separator page"...

Delete macros
I am using Excel 2002. When I click on Tools->Macro->Macros... i see 2 macros. The problem I am having is that I can't delete these macros, the delete button to the right is grayed out. How can I delete these macros? Hi maybe the macros are protected. Try hitting ALT + F11 to open the VBA editor and try to delete the macros / modules there -- Regards Frank Kabel Frankfurt, Germany excel777 wrote: > I am using Excel 2002. When I click on Tools->Macro->Macros... i see > 2 macros. The problem I am having is that I can't delete these > macros, the delete button to ...

deleting email in outlook, freezes before i can delete
i have a file with pics that symetec scanner says is to large. i can receieve email but cannot send any. it freezes before i can delete and says non responding. Hi All, I want to re-raise the old issue of Fax numbers showing up in the Outlook Address book when one is sending an email. I know that this can be stopped by prepending the Contact's fax number with a letter so that Outlook doesn't see it as a valid fax number and therefore doesn't list it. What's always puzzled me, however, is that this fix doesn't work if the fax numbers are changed using an export to CSV...

Locate a specific row or column
Hi all, Could you tell me how to locate a specific row instead of using Mouse to dray the scroll bar? Clara thank you so much for your help In VBA code, you can use: Range("D100").Activate ' Or Range("D1:D100").Select ' Depending on if you want only one cell highlighted or a range of cells. -- Best wishes, Jim "clara" wrote: > Hi all, > > Could you tell me how to locate a specific row instead of using Mouse to > dray the scroll bar? > > Clara > > thank you so much for your help Hi Clara Have you tried goto in the Ed...

OK to delete Deleted Items folder?
I'm afraid I'll have to delete my Deleted Items folder in Outlook 2000. When I try to empty the folder I get a "The messaging interfce has returned an unknown error. If the problem persists Restart Outlook" message. Is it possible to delete the entire folder and replace it with an empty new one? Will it create any problems? TIA Henrik Not possible. Run scanpst.exe against your pst-file to scan it for errors first. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Se...

Transfer of data #2
I have a database of information in excel and need a formula for compiling totals and transferring it to the main worksheet page. Basically it is a payment tracker - I put in todays date, account number, payment amount, etc and hit submit - it then sends this info onto the next worksheet page (the database). On the main page I have weekly, and monthly totals. I need it to update the weekly monthly totals based on the actual week and month - not last 7 days or last 30 days. How can i do this? Ultimately what it needs to do is go to the second page and grab all the info for the curren...

How to delete chart
I created a histogram and want to delete it. I select it and the faint double border apperars. There are no square handles like in 2003. Then I press the Delete key. The faint double border goes away replaced by a single thin black border. The chart is still there and is not able to be selected at all. I entered "delete chart" in the Excel Help window, and there was nothing at all on deleting a chart. Ditto for "remove chart." I got no help searching on the internet either. I have Excel 2007 and Windows XP Professional When the border changes, can you press Delete a...

Delete blank Last page
In a word document where the last page is blank due to editing or whatnot, how do you get rid of the frigg' thing. This is a Visio newsgroup - your question was about Word. However, I have had this problem as you have. Narrowing the margins and line spacing on the page previous to the last may get rid of this annoying "blank" page for you. - Jeff Chapman "silkies" <silkies@discussions.microsoft.com> wrote in message news:BDCC1FF1-50D0-42CE-BA84-868CB26A43AC@microsoft.com... > In a word document where the last page is blank due to editing or > whatnot...

selecting data from a database
I'll try my best to explain what i I want to do.... I have a databse that contains a list of times recorded by athletes over various distances. I would like ot be able to run a macro that compiles a report by selecting personal best times by athletes name for the various distances. the database is continually added to, athletes times are constantly updated so refencing specific cells is not feasible. I currently sort the database by name, distance, best time for that distance so I can see an athletes history but need a method to extract the best times for each discipl...

Having trouble with extra rows at the bottom of the doc
How do I delete the extra rows at the bottom of a doc. I have inherited a document that has 60 rows of data and 3682 rows of empty cells that have the boarder set. When I select and delete them, new ones reappear. I have turned the cell boards off and it still creates empty cells with the boarder. Is there any way to delete these rows? -ken Ken, Are you selecting and then deleting and then saving? HTH, Andy Ken Excel has a habit of retaining "used" cells way beyond where you are currently working. On a worksheet hit CRTL + END to see where you wind up. If far below and...