Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / November 2005

Tip: Looking for answers? Try searching our database.

Delete rows with no data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mindie - 30 Nov 2005 19:49 GMT
I have an excel spreadsheet that I would like it to automatically look at
columns of data and if there is no data or formulas for that column of data
to go ahead and delete the column or if I have it in a row to delete the row.
Is there an easy way to do this?
Gord Dibben - 30 Nov 2005 21:24 GMT
Mindie

This would require VBA macro to be "automatic"

Sub DeleteEmptyRows()
Dim LastRow As Long
''only if entire row is blank
   LastRow = ActiveSheet.UsedRange.Row - 1 + _
           ActiveSheet.UsedRange.Rows.Count
   Application.ScreenUpdating = False
   For r = LastRow To 1 Step -1
       If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
   Next r
End Sub

Sub DeleteEmptycolumns()
Dim Lastcolumn As Long
''only if entire column is blank
   Lastcolumn = ActiveSheet.UsedRange.Column - 1 + _
           ActiveSheet.UsedRange.Columns.Count
   Application.ScreenUpdating = False
   For r = Lastcolumn To 1 Step -1
       If Application.CountA(Columns(r)) = 0 Then Columns(r).Delete
   Next r
End Sub

Gord Dibben Excel MVP

>I have an excel spreadsheet that I would like it to automatically look at
>columns of data and if there is no data or formulas for that column of data
>to go ahead and delete the column or if I have it in a row to delete the row.
> Is there an easy way to do this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.