Delete row if VBA

jessica_p

New Member
Joined
Aug 17, 2018
Messages
10
Hi all,

So I'm new to VBA and macro's.
I've done some research on internet, tried multiple macro's as mentioned on the internet, but can't seem to make it work.


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Local ID[/TD]
[TD]Global ID[/TD]
[TD]Entity[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1008269[/TD]
[TD]1008269[/TD]
[TD]HHG[/TD]
[/TR]
[TR]
[TD]2851990[/TD]
[TD]979889[/TD]
[TD]PPH[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]289144[/TD]
[TD]999807[/TD]
[TD]PPH[/TD]
[/TR]
[TR]
[TD]849008[/TD]
[TD]819733[/TD]
[TD]HHG[/TD]
[/TR]
[TR]
[TD]2008956[/TD]
[TD]2008956[/TD]
[TD]PPH[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 263"]
<colgroup><col span="3"><col></colgroup><tbody>[TR]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][TABLE="class: grid, width: 500"]
<tbody></tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
What I want:
If cell A = empty, then delete entire row.

What Macro I have now:


Do

If InStr(Persnr, 0) Then
ActiveSheet.Rows(row_number & ":" & row_number).Delete
row_number = row_number - 1

End If

Loop Until Persnr = ""


However, prior to wanting to run this macro, I've put in a lot of formulas. So if there's an empty cell in A, there's still a formula in.
Even after removing the formulas from the sheet, somehow the cell still isn't visible as being empty.
So maybe there's the issue?

Could somebody please help me on what the macro should be in order for the rows to be deleted?

Thank you in advance,

Jessica
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Are you happy for all the formulas on the sheet to be replaced with values?
 
Upvote 0
Are you happy for all the formulas on the sheet to be replaced with values?

Hi Fluff,

Sure I am.
The end product requires only values, so I was going to replace the formulas with values anyway.

Only "issue" then is that somehow Excel doesn't see the empty cells as being empty (found out via Find - Special).
 
Upvote 0
Ok, how about
Code:
Sub Delrws()
   With ActiveSheet.UsedRange
      .Value = .Value
   End With
   With Range("A:A").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Perfect! Thank you so much!

So, what was I doing wrong?
I will analyze the formula you inserted, but also would like to know what I did wrong.
 
Upvote 0
At a guess, I suspect that you copied the cells & then did Paste as values (either manually, or with code).
When you do that you will endup with a NullString in any cell where the formula returned ""
Whereas if you do Value=Value that doesn't happen (although I've no idea why)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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