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.

SNLocationProgramVersionData1Data2Data3
111South1P11.11015No
222South2P21.11515No
333South3P11.11015Yes
P32.115
P42.120
444South4P32.21520No

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
:eek:

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,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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