Sorting and Filtering with Empty Cells

royca

New Member
Joined
Jan 27, 2011
Messages
44
Hi Folks,

I have quite a large sheet formatted something like the below. Blank cells share common data with the populated cell above them, maybe not great formatting but it is what I get.

I would like to be able to sort or filter by location for example with the empty cells below South3 being included as if they were South3 (like South3(0), South3(1), South3(2)). Is there a way to do this without breaking into some VBA or filling in every cell? Any ideas would be great.

[TABLE="width: 500"]
<tbody>[TR]
[TD]SN[/TD]
[TD]Location[/TD]
[TD]Program[/TD]
[TD]Version[/TD]
[TD]Data1[/TD]
[TD]Data2[/TD]
[TD]Data3[/TD]
[/TR]
[TR]
[TD]111[/TD]
[TD]South1[/TD]
[TD]P1[/TD]
[TD]1.1[/TD]
[TD]10[/TD]
[TD]15[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]222[/TD]
[TD]South2[/TD]
[TD]P2[/TD]
[TD]1.1[/TD]
[TD]15[/TD]
[TD]15[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]333[/TD]
[TD]South3[/TD]
[TD]P1[/TD]
[TD]1.1[/TD]
[TD]10[/TD]
[TD]15[/TD]
[TD]Yes[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]P3[/TD]
[TD]2.1[/TD]
[TD]15[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]P4[/TD]
[TD]2.1[/TD]
[TD]20[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]444[/TD]
[TD]South4[/TD]
[TD]P3[/TD]
[TD]2.2[/TD]
[TD]15[/TD]
[TD]20[/TD]
[TD]No[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Without using VBA I can only think of using "helper" columns.

Say SN is column A, insert two columns after B and in the new C2 enter this formula and fill it down:

Code:
=IF(A2="",A1,A2)

Follow the same process for the new D2 but referencing column B:

Code:
=IF(B2="",B1,B2)

You'll now filter using columns C and D.
 
Last edited:
Upvote 0
I'm wondering if you are avoiding filling the empty cells simply because of the perceived difficulty of that?

If so, it is easy to fill the blanks with what is above them (without vba) as follows
1. Select the entire data range (or all of columns A:G)
2. Press F5 -> Special... -> Blanks -> OK
3. Now type an = sign, press the up arrow key, hold down the Ctrl key and press Enter
4. Select the entire data range (or all of columns A:G) again, Copy, PasteSpecial -> Values

Done
 
Upvote 0
:eeek:

That's amazing, Peter!
 
Last edited:
Upvote 0
That's a new one for me and pretty cool.

For this one though I was hoping for something that grouped the rows together.
 
Upvote 0
For this one though I was hoping for something that grouped the rows together.
There is nothing that I know of that will necessarily keep those rows 'locked' together in the original order if you might be doing sorting and/or filtering on any column(s) in any order(s).

Depending on just what you have in your real data, about the best bet I think will be along the lines suggested bu Jon (though there are errors in the logic of Jon's formulas).
Here is my adjustment to those formulas and I would just place the new columns to the right of your original table to maintain its integrity.
The formula in H2 is copied across to I2 and down.
Note though that, depending on what sorting/filtering you do, those rows that should be together, could get separated.
If you may want to return to this original order, then to be safe I would also add the new column J, just numbered 1 to n so that you could always re-sort on that column to restore the original order.

Excel Workbook
ABCDEFGHIJ
1SNLocationProgramVersionData1Data2Data3SN2Location2Original
2111South1P11.11015No111South11
3222South2P21.11515No222South22
4333South3P11.11015Yes333South33
5P32.115333South34
6P42.120333South35
7444South4P32.21520No444South46
Sort Filter Empty Cells (2)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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