PDA

View Full Version : Delete All Empty Cells From Range Using VBA / Remove Blank Cells Using Formula



mahmoud-lee
06-09-2013, 05:35 PM
HI
I want this table to be like this

Excel Fox
06-09-2013, 06:21 PM
Mahmoud, the sheet is in filter mode. You cannot expect to have the macro do what you what with the filter mode active. If you remove the filter, you can achieve what you want to do with a simple line of code


Range("A3:E23").SpecialCells(xlCellTypeBlanks).Delete xlUp

mahmoud-lee
06-09-2013, 06:31 PM
I need a formula

Excel Fox
06-09-2013, 07:18 PM
Just use this A26=IFERROR(INDEX(A$3:A$23,SMALL(IF(LEN(A$3:A$23), ROW(INDIRECT("1:"&ROWS(A$3:A$23))),""),ROW(A1))),"") as an array formula, and drag down and across

mahmoud-lee
06-09-2013, 07:32 PM
If the user office 2003

Excel Fox
06-09-2013, 07:40 PM
=IF(ISERROR(INDEX(A$3:A$23,SMALL(IF(LEN(A$3:A$23), ROW (INDIRECT("1:"&ROWS(A$3:A$23))),""),ROW(A1)))),"",INDEX(A$3:A$23,SMALL(IF(LEN(A$3:A$23),ROW (INDIRECT("1:"&ROWS(A$3:A$23))),""),ROW(A1))))

mahmoud-lee
06-09-2013, 08:02 PM
I'm sorry
FORMULA GIVEN EMPTY CELL

Excel Fox
06-09-2013, 09:36 PM
Please avoid statements like "Thank you very much/You are great/etc". If you like a post, just click on the Like button on the post. You can also like the Facebook button on the top of each thread, and post it to your facebook account.

You mention the formula is giving empty cell. Did you confirm the formula as an array formula (http://office.microsoft.com/en-in/excel-help/introducing-array-formulas-in-excel-HA001087290.aspx)?

mahmoud-lee
06-09-2013, 09:38 PM
YES
YOU MEAN LIKE THIS
{=IF(ISERROR(INDEX(A$3:A$23;SMALL(IF(LEN(A$3:A$23) ;ROW (INDIRECT("1:"&ROWS(A$3:A$23)));"");ROW(A2))));"";INDEX(A$3:A$23;SMALL(IF(LEN(A$3:A$23);ROW (INDIRECT("1:"&ROWS(A$3:A$23)));"");ROW(A2))))}

Excel Fox
06-09-2013, 09:55 PM
Post the workbook where you've used this array formula. By the way, why does your formula start with Row(A2), when I used Row(A1)

Admin
06-09-2013, 09:59 PM
Hi

Another way to trap the error...

=IF(ROWS(A$26:A26)<=COUNTA(A$3:A$23);INDEX(A$3:A$23;SMALL(IF(LEN(A$3: A$23);ROW(A$3:A$23)-ROW(A$3)+1);ROWS(A$26:A26)));"")

again it's an array formula. confirmed with CTRL+SHIFT+ENTER

LalitPandey87
06-10-2013, 07:42 AM
Hi

Another way to trap the error...

=IF(ROWS(A$26:A26)<=COUNTA(A$3:A$23);INDEX(A$3:A$23;SMALL(IF(LEN(A$3: A$23);ROW(A$3:A$23)-ROW(A$3)+1);ROWS(A$26:A26)));"")

again it's an array formula. confirmed with CTRL+SHIFT+ENTER

Formula will look like this:


=IF(ROWS(A$26:A26)<=COUNTA(A$3:A$23),INDEX(A$3:A$23,SMALL(IF(LEN(A$3: A$23),ROW(A$3:A$23)-ROW(A$3)+1),ROWS(A$26:A26))),"")

mahmoud-lee
06-10-2013, 08:37 AM
Thank you all

Admin
06-10-2013, 09:05 AM
Formula will look like this:


=IF(ROWS(A$26:A26)<=COUNTA(A$3:A$23),INDEX(A$3:A$23,SMALL(IF(LEN(A$3: A$23),ROW(A$3:A$23)-ROW(A$3)+1),ROWS(A$26:A26))),"")

That's intentional. I guess the OP is using European version of Office.