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.


Local IDGlobal IDEntity
10082691008269HHG
2851990979889PPH
289144999807PPH
849008819733HHG
20089562008956PPH

<tbody>
</tbody>

<tbody></tbody>

<colgroup><col span="3"><col></colgroup><tbody>
</tbody>
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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