Will this single line VBA command delete empty cells?

excelos

Active Member
Joined
Sep 25, 2011
Messages
329
Hello


Will this command delete empty cells in that range?


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

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,508
Office Version
  1. 365
Platform
  1. Windows
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:

excelos

Active Member
Joined
Sep 25, 2011
Messages
329
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.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,508
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,425
Messages
5,528,688
Members
409,830
Latest member
KT50

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top