Solved

Delete blank rows sub

Posted on 2011-03-14
4
192 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

837 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