Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default How to create a macro that deletes every blank row in a spreadshee

Hi,

This may do the trick. Call the function that follows like so (test before
running live):

Sub TestDelete()
Call RowsJoinData(5) '<where column 5 (E) is blank for every row to delete
end sub

Public Function RowsJoinData(argColumn As Integer)
'DELETES ENTIRE ROW WHERE CRITERIA CELL IS BLANK
Dim lX As Long
Dim lCount As Long
Application.ScreenUpdating = False
ActiveSheet.DisplayAutomaticPageBreaks = False
Application.Calculation = xlCalculationManual
lCount = ActiveSheet.UsedRange.Rows.Count
For lX = lCount To 1 Step -1
If Cells(lX, argColumn).FormulaR1C1 = "" Then
Rows(lX).EntireRow.Delete
End If
Next lX
Application.ScreenUpdating = True
ActiveSheet.DisplayAutomaticPageBreaks = True
Application.Calculation = xlCalculationAutomatic
End Function

HTH/

"Grd" wrote:

Hi

I have a 4000 row spreadsheet with approximately 33 columns and I have about
about 300 intermittent blank lines.

How can create a macro in the file to automate the process of deleting these
empty rows which I do manually?

I don't want to use the autofilter function to deal with this problem. I
would if possible to do this with a button or shortcut.

Anyone can help me this.

Thanks very much in advance
Janet

  #2   Report Post  
Posted to microsoft.public.excel.programming
Grd Grd is offline
external usenet poster
 
Posts: 118
Default How to create a macro that deletes every blank row in a spread

Worked great
Thanks very much

"quartz" wrote:

Hi,

This may do the trick. Call the function that follows like so (test before
running live):

Sub TestDelete()
Call RowsJoinData(5) '<where column 5 (E) is blank for every row to delete
end sub

Public Function RowsJoinData(argColumn As Integer)
'DELETES ENTIRE ROW WHERE CRITERIA CELL IS BLANK
Dim lX As Long
Dim lCount As Long
Application.ScreenUpdating = False
ActiveSheet.DisplayAutomaticPageBreaks = False
Application.Calculation = xlCalculationManual
lCount = ActiveSheet.UsedRange.Rows.Count
For lX = lCount To 1 Step -1
If Cells(lX, argColumn).FormulaR1C1 = "" Then
Rows(lX).EntireRow.Delete
End If
Next lX
Application.ScreenUpdating = True
ActiveSheet.DisplayAutomaticPageBreaks = True
Application.Calculation = xlCalculationAutomatic
End Function

HTH/

"Grd" wrote:

Hi

I have a 4000 row spreadsheet with approximately 33 columns and I have about
about 300 intermittent blank lines.

How can create a macro in the file to automate the process of deleting these
empty rows which I do manually?

I don't want to use the autofilter function to deal with this problem. I
would if possible to do this with a button or shortcut.

Anyone can help me this.

Thanks very much in advance
Janet

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
Macro deletes row in range, macro then skips the row moved up steven.holloway Excel Discussion (Misc queries) 8 June 11th 08 11:40 AM
Save using Macro but test to see if an error appears on spreadshee jfaz Excel Discussion (Misc queries) 1 September 18th 06 04:38 PM
Macro that deletes every third row....+ ajjag Excel Discussion (Misc queries) 4 June 27th 06 06:03 PM
WHEN DOWNLOADING A TEXTFILE EXCEL DELETES BLANK ROWS - STOP THIS? shell3 Excel Worksheet Functions 0 October 21st 05 03:29 PM
Macro that deletes certain rows and not others Roger[_20_] Excel Programming 8 May 3rd 05 12:02 AM


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