Don't show blanks when condition isn't met

Karlski

New Member
Joined
May 16, 2017
Messages
9
Hello,

I have done a normal IF statement to match a condition to copy over data. As expected, when the condition is not met a blank row appears. I was wondering if anyone can help how so that it just skip to the next line that meets the condition and have a list of data with no blanks.

Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Re: How to not show blanks when condition isn't met

"Eliminating blank cells in a range"

Taken from http://www.cpearson.com/excel/noblanks.htm

Worksheet Formulas
BlanksRange1.png
The image to the left illustrates a range named [FONT=&quot]BlanksRange
that contains a combination of values and blank cells. Although the values are in alphabetical order, this is by no means necessary. It is for illustration only. The values will be extracted and will appear in the no-blanks range in the order in which the appear in the original data.[/FONT]

To use the formula, paste it into the first cell of [FONT=&quot]NoBlanksRange and then copy it down to fill that range. The [FONT=&quot]NoBlanksRange[/FONT] should have as many rows as [FONT=&quot]BlanksRange[/FONT]. Any unused cells in [FONT=&quot]BlanksRange[/FONT] will contain empty values. This is an array formula, so you must press [FONT=&quot]CTRL SHIFT ENTER[/FONT] rather than just [FONT=&quot]ENTER[/FONT]when you first enter the formula and whenever you edit it later, but you do not array enter it into the entire range at once. Array enter the formula into the first cell of [FONT=&quot]NoBlanksRange[/FONT] and then fill down to the last cell of [FONT=&quot]NoBlanksRange[/FONT]. The formula is:[/FONT]
=IF(ROW()-ROW(NoBlanksRange)+1>ROWS(BlanksRange)-
COUNTBLANK(BlanksRange),"",INDIRECT(ADDRESS(SMALL(
(IF(BlanksRange<>"",ROW(BlanksRange),ROW()+ROWS(BlanksRange))),
ROW()-ROW(NoBlanksRange)+1),COLUMN(BlanksRange),4)))
The formula above is split into several lines for readability. In practice, it should be entered as a single line. A simpler method is available in Excel 2007 and later versions, using the [FONT=&quot]IFERROR function.

[FONT=&quot]=IFERROR(INDEX(BlanksRange,SMALL((IF(LEN(BlanksRange),ROW(INDIRECT("1:"&ROWS(BlanksRange))))),ROW(A1)),1),"")[/FONT]

Enter this formula into the first cell of [FONT=&quot]NoBlanksRange[/FONT] and copy it down through the last cell of [FONT=&quot]NoBlanksRange[/FONT]. Like the other formulas, this is an array formula, so enter it with [FONT=&quot]CTRL SHIFT ENTER[/FONT]rather than just [FONT=&quot]ENTER[/FONT]. This formula is for extracting the non-blank elements to a vertical range -- a range in a single column that spans several rows. If you want the results in a single row spanning several columns, use the following array formula, where the result range is named [FONT=&quot]NoBlanksRow[/FONT].[/FONT]

=IF(COLUMN()-COLUMN(NoBlanksRow)+1>ROWS(BlanksRange)-
COUNTBLANK(BlanksRange),"",INDIRECT(ADDRESS(SMALL(
(IF(BlanksRange<>"",ROW(BlanksRange),COLUMN()+ROWS(BlanksRange))),
COLUMN()-COLUMN(NoBlanksRow)+1),COLUMN(BlanksRange),4)))
Array enter this formula into the first cell of [FONT=&quot]NoBlanksRow and fill to the right through the last cell of[FONT=&quot]NoBlanksRow[/FONT].[/FONT]
 
Upvote 0
You'll need to provide sample data; it's not possible to help you from just your description. If the data is sensitive then feel free to change it before posting.

WBD
 
Upvote 0
You'll need to provide sample data; it's not possible to help you from just your description. If the data is sensitive then feel free to change it before posting.

WBD


Sorry, a simple example is as below:

[TABLE="width: 0"]
<tbody>[TR]
[TD]Customer Number Number
[/TD]
[TD]Code
[/TD]
[TD]Date
[/TD]
[/TR]
[TR]
[TD]123
[/TD]
[TD]F4
[/TD]
[TD]01/10/2017
[/TD]
[/TR]
[TR]
[TD]1234
[/TD]
[TD]E3
[/TD]
[TD]05/10/2017
[/TD]
[/TR]
[TR]
[TD]5678
[/TD]
[TD]P9
[/TD]
[TD]04/10/2017
[/TD]
[/TR]
[TR]
[TD]3214
[/TD]
[TD]F4
[/TD]
[TD]04/10/2017
[/TD]
[/TR]
[TR]
[TD]6578
[/TD]
[TD]H5
[/TD]
[TD]03/10/2017
[/TD]
[/TR]
[TR]
[TD]4389
[/TD]
[TD]F4
[/TD]
[TD]05/10/2017
[/TD]
[/TR]
[TR]
[TD]980
[/TD]
[TD]P9
[/TD]
[TD]26/10/2017
[/TD]
[/TR]
</tbody>[/TABLE]

If the code is 'F4' for example I would like all the data to display on a new tab. However, for the rows the code is not 'F4' I don't want there to be any blanks. So basically, for all rows that contain 'F4', the full row of data to be displayed on the next tab with no blank spaces between the information.
 
Upvote 0
something like...

E2=IFERROR(INDEX($A$2:$C$8,SMALL(IF($B$2:$B$8=$D$1,ROW($A$2:$A$8)-ROW($A$2)+1),ROWS($E$2:E2)),COLUMNS($E2:E2)),"") Control Shift Enter

[TABLE="class: grid"]
<tbody>[TR]
[TD]Row\Col[/TD]
[TD]
A​
[/TD]
[TD]
B​
[/TD]
[TD]
C​
[/TD]
[TD]
D​
[/TD]
[TD]
E​
[/TD]
[TD]
F​
[/TD]
[TD]
G​
[/TD]
[/TR]
[TR]
[TD]
1​
[/TD]
[TD]Customer Number Number[/TD]
[TD]Code[/TD]
[TD]Date[/TD]
[TD]F4[/TD]
[TD]Customer Number Number[/TD]
[TD]Code[/TD]
[TD]Date[/TD]
[/TR]
[TR]
[TD]
2​
[/TD]
[TD]
123​
[/TD]
[TD]F4[/TD]
[TD]
10/1/2017​
[/TD]
[TD][/TD]
[TD]
123​
[/TD]
[TD]F4[/TD]
[TD]
10/1/2017​
[/TD]
[/TR]
[TR]
[TD]
3​
[/TD]
[TD]
1234​
[/TD]
[TD]E3[/TD]
[TD]
10/5/2017​
[/TD]
[TD][/TD]
[TD]
3214​
[/TD]
[TD]F4[/TD]
[TD]
10/4/2017​
[/TD]
[/TR]
[TR]
[TD]
4​
[/TD]
[TD]
5678​
[/TD]
[TD]P9[/TD]
[TD]
10/4/2017​
[/TD]
[TD][/TD]
[TD]
4389​
[/TD]
[TD]F4[/TD]
[TD]
10/5/2017​
[/TD]
[/TR]
[TR]
[TD]
5​
[/TD]
[TD]
3214​
[/TD]
[TD]F4[/TD]
[TD]
10/4/2017​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
6​
[/TD]
[TD]
6578​
[/TD]
[TD]H5[/TD]
[TD]
10/3/2017​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
7​
[/TD]
[TD]
4389​
[/TD]
[TD]F4[/TD]
[TD]
10/5/2017​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
8​
[/TD]
[TD]
980​
[/TD]
[TD]P9[/TD]
[TD]
10/26/2017​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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