Eliminate Blank cells and Move up Data Code

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
In My Range G20:G32 I Have:

[TABLE="width: 87"]
<tbody>[TR]
[TD="class: xl64, width: 87"] Excel 2010
G
Able
Bob
Cathy
Daryl
Edward
Fred
Marvin
Pete

<colgroup><col style="width: 25pxpx"><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]20[/TD]

[TD="align: center"]21[/TD]

[TD="align: center"]22[/TD]
[TD="align: right"][/TD]

[TD="align: center"]23[/TD]

[TD="align: center"]24[/TD]
[TD="align: right"][/TD]

[TD="align: center"]25[/TD]

[TD="align: center"]26[/TD]

[TD="align: center"]27[/TD]

[TD="align: center"]28[/TD]
[TD="align: right"][/TD]

[TD="align: center"]29[/TD]

[TD="align: center"]30[/TD]
[TD="align: right"][/TD]

[TD="align: center"]31[/TD]
[TD="align: right"][/TD]

[TD="align: center"]32[/TD]

</tbody>
Sheet1
[/TD]
[/TR]
</tbody>[/TABLE]

This code is not working - Can someone REPAIR my FAULTY LOGIC?

Code:
Sub EliminateBlankRows()
LR = Range("G" & Rows.Count).End(xlUp).Row
Set Rng = Range("G20:G" & LR)
Application.Calculation = xlCalculationManual
With Rng
    For i = LR To Rng(1).Row + 1 Step -1
        If Cells(i, 7).Value = "" Or Cells(i, 7).Offset(-1).Value = "" Then
            Application.CutCopyMode = False
            Cells(i, 7).Cut Destination:=Cells(i, 7).Offset(-1, 0)
            i = i - 1
        Else
'        j = j - 1
'        i = i + j
        End If
    Next i
End With
Application.Calculation = xlCalculationAutomatic
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try
Code:
Sub delblank()
Dim lr As Long
lr = Cells(Rows.Count, "G").End(xlUp).Row

For i = lr To 20 Step -1
    If Cells(i, "G") = "" Then Cells(i, "G").Delete Shift:=xlUp
Next i
End Sub
 
Upvote 0
Another way
Code:
Sub jim_may()
   Range("G20:G32").SpecialCells(xlBlanks).Delete xlUp
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top