+ Reply to Thread
Results 1 to 6 of 6

Moving Text upwards into empty rows

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-25-2012
    Location
    Ventura, united States
    MS-Off Ver
    Excel 2010
    Posts
    346

    Moving Text upwards into empty rows

    This is the best that I can do for getting rid of blank rows. It's a little bit slow, and alternatively I would like to move all the text upward into any empty spaces without deleting rows. Any ideas?


    Range("A2401").Select
    For i = 1 To 2400
    ActiveCell.Offset(-1, 0).Select
    If ActiveCell.Value = Empty Then
    ActiveCell.EntireRow.Delete
    End If
    Next i

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Moving Text upwards into empty rows

    why not delete het empty (blanc) rows?

    Sub DeleteBlankRows()
    Dim r As Long
    For r = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
    If Cells(r, 1) = "" Then Rows(r).Delete
    Next r
    End Sub
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Moving Text upwards into empty rows

    To be honest, you just need one line

    Range("A1:A2400").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

  4. #4
    Forum Contributor
    Join Date
    09-25-2012
    Location
    Ventura, united States
    MS-Off Ver
    Excel 2010
    Posts
    346

    Re: Moving Text upwards into empty rows

    aHAA. JieJenn - I had no idea it was that easy. Thanks.

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Moving Text upwards into empty rows

    @JieJenn

    In your code (#3) you need to hard code the range.

    In my found code (#2) it automatic counts all rows.

    I think (#2) is easier for common use.

    By the way, I think one line is not always better than more lines.

    If it is easier to read to code if it is more lines, i prefer the last one.

    In that case it is easier to change (to my opinion)

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Moving Text upwards into empty rows

    You can always it do dynamic range

    Range("A1:A" & Cells(Rows.count,1).end(xlup).row).SpecialCells(xlCellTypeBlanks).EntireRow.Delete

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1