Sorting Blanks from an XLOOKUP

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Good morning, I hope you're all well!
I'm using XLOOKUP for the first time and having an issue where when I sort the data in this column by A to Z, it's putting all the blanks first, and the data I want at the bottom of the table.
This has never happened in the past (where I've used VLOOKUP for instance), and doesn't happen with any other columns with formulas in.

I've tried the following:
Excel Formula:
=IF(ISBLANK([@CATEGORY]),"",XLOOKUP([@CATEGORY],Budgets[Category],Budgets[Material/Plant]))

Excel Formula:
=LET(X,XLOOKUP([@CATEGORY],Budgets[Category],Budgets[Material/Plant],""),IF(X="","",X))

and:
Excel Formula:
=IF(XLOOKUP([@CATEGORY],Budgets[Category],Budgets[Material/Plant],"")="","",XLOOKUP([@CATEGORY],Budgets[Category],Budgets[Material/Plant],""))

Everything I try, this particular column sorts blanks, rather than visible data.
I'm stumped.

If anyone can help, it would be greatly appreciated.

Thank you.
Regards
Marhier
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
That's exactly what I would expect as a null string "" is a zero length string & therefore comes before the letter A alphabetically.
 
Upvote 0
How comes this doesn't happen with similar fucntions like VLOOKUP, or any other cell where I have formula preceeded by an IF(ISBLANK statement?
 
Upvote 0
Are those other formulae looking at text values or numbers?
 
Upvote 0
Ok, I see what you mean now.
The others are looking at numbers; this issue only occurs when the formula is looking at text.

Is there a way round this?

I thought about VBA to clear blanks in that range:

VBA Code:
Set Rng = Range("F8", Cells(Rows.Count, 1).End(xlUp))
For Each cell In Rng
    If cell.Value = "" Then
    cell.ClearContents
    End If

My issue with that is if I need to generate my table again becuase the data set grows, I'll need that formula in thoese cells so it picks up what I need.

Any advice is greatly appreciated.
Thank you
Regards
Marhier
 
Upvote 0
Can easily VBA that formula back in, I guess.

Would be nice if it would just not sort the blanks, lol!
 
Upvote 0
The problem with using a macro to remove the formula, is that you then have to figure which cells need the formula replying at a latter date. Especially if the data has been re-sorted on a different column.
 
Upvote 0
My 'Generate' button clears said table first and starts a fresh, so adding formula in at the beginning and clearing it at the end via VBA will work just fine for my use case.

I'm writing the code now, will test and report back.
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

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