Sorting

J

Joe Gieder

I tried looking through Google but to no avail. I'm
trying to automatically sort a range of data containing
two columns using VBA not the sort under Data>Sort. The
cell I'm want to sort on is text (company names) and is a
formula based on information on another worksheet. My
dilema is that when I sort this way
..Range("a34:b202").Sort Key1:=.Range("a34"),
Order1:=xlAscending
the results come out alphabetically but if there are
blank cells between the last company and A202 the blanks
are at the beginning and I need them at the bottom. Is
there a way to sort with putting the blanks at the end?
Could I maybe add INDEX or something to the formula to
have it do it? the fomula I use is:
{=IF(ISNA(INDEX('Priced BOM'!$W$3:$W$1010,MATCH(0,COUNTIF
($A$33:A33,'Priced BOM'!$W$3:$W$1010),0))),"",INDEX
('Priced BOM'!$W$3:$W$1010,MATCH(0,COUNTIF
($A$33:A33,'Priced BOM'!$W$3:$W$1010),0)))}
Thanks for all your help
Joe
 
B

Bob Kilmer

I might consider putting "zzzzzzzzzzzzzzzz"s (or other useful but unique
values) in the blank cells programatically, sort, then remove the
"zzzzzzzzzzzzzzzzzz"s using a replace the "zzz...." with a null string.

Or use a helper column filled with formulas and/or values that better
represents the sort I want, sort on the helper column, then drop it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top