Solved

Delete blank rows sub

Posted on 2011-03-14
4
194 Views
Last Modified: 2012-05-11
Hi,

I have attached a ss where i want a piece of code that can count until the last row using ColA and then delete any blank rows (there is formula in the blank rows)

See attached

Thanks
Seamus
test1.xls
0
Comment
Question by:Seamus2626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35127183
Something like:
Sub TidyUp()
   With Sheets("Sheet1")
    .Range("A1").CurrentRegion.Sort Key1:=.Range("A2"), Order1:=xlAscending, Header:= _
        xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
      .Range(.Cells(.Rows.Count, "A").End(xlUp).Offset(1), .Cells.SpecialCells(xlCellTypeLastCell)).Clear
   End With
End Sub

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 35127190
Magic

Thanks Rory

Seamus
0
 
LVL 6

Expert Comment

by:Russell Lucas
ID: 35127214
Just as an alternative solution:-


Sub Remove_Blanks()
Dim i As Integer
i = 2
While ExitCondition = False
    If Sheet1.Range("I" & i).Formula = "" Then ExitCondition = True
    If Sheet1.Range("A" & i).Value = "" Then
        Sheet1.Rows(i).Delete
    Else
        i = i + 1
    End If
Wend
End Sub

Open in new window

0
 

Author Comment

by:Seamus2626
ID: 35146362
Thanks Funinig_Stroll, appreciate the additional info

Cheers,
Seamus
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question