Will this single line VBA command delete empty cells?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
592
Office Version
  1. 365
Platform
  1. Windows
Hello


Will this command delete empty cells in that range?


Range("A1:A10").SpecialCells(xlCellTypeBlanks).Rows.Delete Shift:=xlShiftUp
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Did you try it?

One of the best ways of learning VBA is through trial and error. So don't be afraid to try some things out for yourself.
For a question like this, by testing it you will be able to see pretty easily and pretty definitely whether it works or not.
 
Last edited:
Upvote 0
Did you try it?

One of the best ways of learning VBA is through trial and error. So don't be afraid to try some things out for yourself.
For a question like this, by testing it you will be able to see pretty easily and pretty definitely whether it works or not.

It seems to work, although it left one cell undeleted.

However, I need it to work for cells that don't have values but may have formulas. Any idea? I checked the manual and it doesn't seem to have a term for it.
 
Upvote 0
It seems to work, although it left one cell undeleted.
Then it is probably not really blank; it probably has a formula or a space or something (a single space is NOT the same as blank/empty).

If you want to delete cells that have formulas that are returning nothing, then see here: https://www.mrexcel.com/forum/excel...lete-blank-rows-formula-but-has-no-value.html

Another option would be to convert the formulas to hard-coded values, if you are able to do that. Then the cells would truly be blank and the first method would work.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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