Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Howcan I delete blank rows efficiently

Question from VB novice...

Can someone suggest how to make the follwoing macro more efficient ?

It will process 40K plus rows and is very slow.

I've tried adjusting the chunk processing size from, 100 to 5000. Smaller
chunk appears to be faster.

All suggestions welcome...

thanks in advance...


Dim Rng As Range
Dim RawDataRowNdx As Long
Dim LastRowOfRawData As Long
' Turn Screen Updateing and sheet Calculation OFF to go faster
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
' Set sheet to Raw Data Area sheet
'
Sheets("Raw Data Area").Select
'
' Find Last Row of Data
LastRowOfRawData = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


'
' Delete All Blank Rows in 100 row chunks
'
For RawDataRowNdx = 100 To LastRowOfRawData Step 100
Range("N1:N" & RawDataRowNdx).SpecialCells(xlBlanks).EntireRow.De lete
Application.StatusBar = RawDataRowNdx & "K Records Processed... Still
Working!!!"
Next RawDataRowNdx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Howcan I delete blank rows efficiently

Hi

You can sort first and delete it in one step
EasyFilter have a optionn to do this also
http://www.rondebruin.nl/easyfilter.htm


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



"needyourhelp" wrote in message ...
Question from VB novice...

Can someone suggest how to make the follwoing macro more efficient ?

It will process 40K plus rows and is very slow.

I've tried adjusting the chunk processing size from, 100 to 5000. Smaller
chunk appears to be faster.

All suggestions welcome...

thanks in advance...


Dim Rng As Range
Dim RawDataRowNdx As Long
Dim LastRowOfRawData As Long
' Turn Screen Updateing and sheet Calculation OFF to go faster
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
' Set sheet to Raw Data Area sheet
'
Sheets("Raw Data Area").Select
'
' Find Last Row of Data
LastRowOfRawData = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


'
' Delete All Blank Rows in 100 row chunks
'
For RawDataRowNdx = 100 To LastRowOfRawData Step 100
Range("N1:N" & RawDataRowNdx).SpecialCells(xlBlanks).EntireRow.De lete
Application.StatusBar = RawDataRowNdx & "K Records Processed... Still
Working!!!"
Next RawDataRowNdx



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Howcan I delete blank rows efficiently

The following code assumes that Column "O" is empty and not used
and that data bewteen columns A-N is to be deleted, if not just alter
the code to suit.

Like Ron's suggestion, it sorts the data, remove blank rows and then
sort the data back in its original order (less blanks)



Dim Rng As Range
Dim LastRowOfRawData As Long
' Turn Screen Updateing and sheet Calculation OFF to go faster
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
' Set sheet to Raw Data Area sheet
'
Sheets("Raw Data Area").Select
'
' Find Last Row of Data
LastRowOfRawData = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


Range("O" & LastRowOfRawData).Select
ActiveCell.Value = Selection.Row
ActiveCell.Offset(-1, 0).Value = Selection.Row - 1
Range(ActiveCell.Offset(-1, 0), ActiveCell).Select


Selection.AutoFill Destination:=Range("O1", ActiveCell.Offset(1,
0)), Type:=xlFillDefault
Columns("A:O").Select
Selection.Sort Key1:=Range("N1"), Order1:=xlAscending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Range("N1").Select
Selection.End(xlDown).Select

Selection.Offset(1, 1).Select
Range("A" & ActiveCell.Row, ActiveCell.End(xlDown)).Select
Selection.ClearContents

Columns("A:O").Select
Selection.Sort Key1:=Range("O1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Columns("O:O").Select
Selection.ClearContents

Range("A1").Select

HTH

Tony

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Howcan I delete blank rows efficiently

Sorry, just re-read my own post and should have said :

"The following code assumes that Column "O" ........ and that data
bewteen AND INCLUDING columns A-N is to be deleted, etc etc "

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Howcan I delete blank rows efficiently

Ron,

I downloaded easyfilter it works great...

Now, How do you call it from a VBA macro so it is automated ?

thanks,

Tim



"Ron de Bruin" wrote:

Hi

You can sort first and delete it in one step
EasyFilter have a optionn to do this also
http://www.rondebruin.nl/easyfilter.htm


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



"needyourhelp" wrote in message ...
Question from VB novice...

Can someone suggest how to make the follwoing macro more efficient ?

It will process 40K plus rows and is very slow.

I've tried adjusting the chunk processing size from, 100 to 5000. Smaller
chunk appears to be faster.

All suggestions welcome...

thanks in advance...


Dim Rng As Range
Dim RawDataRowNdx As Long
Dim LastRowOfRawData As Long
' Turn Screen Updateing and sheet Calculation OFF to go faster
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
' Set sheet to Raw Data Area sheet
'
Sheets("Raw Data Area").Select
'
' Find Last Row of Data
LastRowOfRawData = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


'
' Delete All Blank Rows in 100 row chunks
'
For RawDataRowNdx = 100 To LastRowOfRawData Step 100
Range("N1:N" & RawDataRowNdx).SpecialCells(xlBlanks).EntireRow.De lete
Application.StatusBar = RawDataRowNdx & "K Records Processed... Still
Working!!!"
Next RawDataRowNdx






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Howcan I delete blank rows efficiently

You can't access EasyFiler with code
Start with your macro recorder and record the things you want.


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



"needyourhelp" wrote in message ...
Ron,

I downloaded easyfilter it works great...

Now, How do you call it from a VBA macro so it is automated ?

thanks,

Tim



"Ron de Bruin" wrote:

Hi

You can sort first and delete it in one step
EasyFilter have a optionn to do this also
http://www.rondebruin.nl/easyfilter.htm


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



"needyourhelp" wrote in message
...
Question from VB novice...

Can someone suggest how to make the follwoing macro more efficient ?

It will process 40K plus rows and is very slow.

I've tried adjusting the chunk processing size from, 100 to 5000. Smaller
chunk appears to be faster.

All suggestions welcome...

thanks in advance...


Dim Rng As Range
Dim RawDataRowNdx As Long
Dim LastRowOfRawData As Long
' Turn Screen Updateing and sheet Calculation OFF to go faster
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'
' Set sheet to Raw Data Area sheet
'
Sheets("Raw Data Area").Select
'
' Find Last Row of Data
LastRowOfRawData = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


'
' Delete All Blank Rows in 100 row chunks
'
For RawDataRowNdx = 100 To LastRowOfRawData Step 100
Range("N1:N" & RawDataRowNdx).SpecialCells(xlBlanks).EntireRow.De lete
Application.StatusBar = RawDataRowNdx & "K Records Processed... Still
Working!!!"
Next RawDataRowNdx






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
Delete blank rows if more than one Kjellk Excel Discussion (Misc queries) 5 June 10th 09 06:17 AM
Delete Blank Rows Heather Excel Discussion (Misc queries) 9 July 15th 08 09:32 PM
delete blank rows Pam C Excel Discussion (Misc queries) 1 January 17th 06 07:13 PM
Delete blank rows djh Excel Programming 2 October 26th 04 02:17 PM
Delete blank row only if 2 consecutive blank rows Amy Excel Programming 2 October 21st 04 05:24 PM


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