Delete line in a Table when the the cell is empty

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Good morning,

Is it possible to delete a whole line with VBA when in my case in column W the values in the cells starting from line 7 until the end are empty with the push of a button?

Thank you for your time?

Romano
 
Try the below... ( @bebo021999 ) can confirm also if correct....

VBA Code:
Sub Del_Blank()
  Dim Rng As Range
  On Error Resume Next
  Set Rng = Range("Table_Query_from_A100[[[COLOR=rgb(226, 80, 65)]Column15[/COLOR]]]").SpecialCells(xlCellTypeBlanks) 'Change the text in red to your column header name...e.g. Column15 to whatever your header name is
  On Error GoTo 0
  If Not Rng Is Nothing Then
    Rng.Delete Shift:=xlUp
  End If
End Sub
So like this

VBA Code:
Sub Del_Blank()
Dim Rng As Range
  On Error Resume Next
  Set Rng = Range("Table_Query_from_A100[[[COLOR=rgb(226, 80, 65)]Nieuwe Ikp  €[/COLOR]]]").SpecialCells(xlCellTypeBlanks) 'Change the text in red to your column header name...e.g. Column15 to whatever your header name is
  On Error GoTo 0
  If Not Rng Is Nothing Then
    Rng.Delete Shift:=xlUp
  End If
End Sub

If this is correct then nothing happens unfortunately.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Sub Del_Blank() Dim Rng As Range On Error Resume Next Set Rng = Range("Table_Query_from_A100[[Nieuwe Ikp €]]").SpecialCells(xlCellTypeBlanks) 'Change the text in red to your column header name...e.g. Column15 to whatever your header name is On Error GoTo 0 If Not Rng Is Nothing Then Rng.Delete Shift:=xlUp End If End Sub

Use this...

VBA Code:
Sub Del_Blank()
Dim Rng As Range
  On Error Resume Next
  Set Rng = Range("Table_Query_from_A100[[Nieuwe Ikp  €]]").SpecialCells(xlCellTypeBlanks) 'Change the text in red to your column header name...e.g. Column15 to whatever your header name is
  On Error GoTo 0
  If Not Rng Is Nothing Then
    Rng.Delete Shift:=xlUp
  End If
End Sub
 
Upvote 0
Solution
Use this...

VBA Code:
Sub Del_Blank()
Dim Rng As Range
  On Error Resume Next
  Set Rng = Range("Table_Query_from_A100[[Nieuwe Ikp  €]]").SpecialCells(xlCellTypeBlanks) 'Change the text in red to your column header name...e.g. Column15 to whatever your header name is
  On Error GoTo 0
  If Not Rng Is Nothing Then
    Rng.Delete Shift:=xlUp
  End If
End Sub
It works, thank you for your efforts. Have a nice day.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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