Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Macro to delete blank rows in a data range

Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro to delete blank rows in a data range

try:

Sub macro_der()
Dim i As Long, nLastRow As Long
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Set r = Rows(nLastRow + 1)
For i = 1 To nLastRow
If Application.CountA(Rows(i)) = 0 Then
Set r = Union(r, Rows(i))
End If
Next
r.Delete
End Sub

--
Gary''s Student - gsnu200776


"Youlan" wrote:

Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Macro to delete blank rows in a data range

Hi

This routine will look at cells in column A and delete entire row if the
cell is empty.

Sub RemoveBlankRows()
Dim TargetRange As Range
Const TargetColumn As Integer = 1 'Check fo empty cells in coloumn A
Set TargetRange = Range(Cells(1, TargetColumn), Cells(65536,
TargetColumn).End(xlUp))
rowcount = TargetRange.Rows.Count
For r = rowcount To 1 Step -1
If Cells(r, 1).Value = "" Then Rows(r).Delete
Next
End Sub

Regards,

Per

"Youlan" skrev i meddelelsen
...
Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to
when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 272
Default Macro to delete blank rows in a data range

Sub DeleteBlankRows()
Cells.EntireRow.Hidden=False
Cells.ColumnDifferences(Cells(Cells.Count)).Entire Row.Hidden=True
Cells.SpecialCells(xlCellTypeVisible).Delete
Cells.EntireRow.Hidden=False
End Sub

"Youlan" wrote:

Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro to delete blank rows in a data range

Without a macro...........Select a column and
F5SpecialBlanksOKEditDeleteEntire Rows


Gord Dibben MS Excel MVP

On Fri, 28 Mar 2008 08:17:01 -0700, Youlan
wrote:

Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default Macro to delete blank rows in a data range

Thank you very much, it"s nice and simple and was very helpful to me.

Diana Vazian

"Gord Dibben" wrote:

Without a macro...........Select a column and
F5SpecialBlanksOKEditDeleteEntire Rows


Gord Dibben MS Excel MVP

On Fri, 28 Mar 2008 08:17:01 -0700, Youlan
wrote:

Hi,

I'm using Excel 2002 and I'm working in a spreasheet with data copied from
an external source. I need to automatically delete the blank rows without
having to go through the entire document. Also their is no set format to when
and how many blank rows are in the document.

Can anyone help?

Thanks in advance.



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
reformating data- how to delete alternate blank rows quickly datamanipulator Excel Discussion (Misc queries) 4 November 27th 07 04:41 PM
How do I delete blank rows (rows alternate data, blank, data, etc ncochrax Excel Discussion (Misc queries) 2 June 27th 07 04:40 AM
MACRO HELP - deleting rows containing a range of blank cells DavidHawes Excel Discussion (Misc queries) 9 February 26th 07 03:40 PM
delete rows in range - macro hindu cliparts Excel Worksheet Functions 0 November 16th 06 09:54 PM
Delete blank rows Macro Richard Excel Discussion (Misc queries) 3 November 4th 05 08:02 AM


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