Sorting with blank rows

tucsondonpepe

New Member
Joined
Jan 30, 2022
Messages
43
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi,

I need help sorting the table with VBA code.

There are four rows and three columns of data.
The sort is on Last Name, then First Name

When I use the standard sort procedure, the blank rows are listed as rows 1 and 2.

I appreciate the help.

Joe
 

Attachments

  • 2023-05-08 Mr Excel-01.jpg
    2023-05-08 Mr Excel-01.jpg
    58.9 KB · Views: 7

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I don't understand what your question/concern is.
Whenever I sort, the blank rows always appear at the bottom, as expected.

Can you show us three images:
- the BEFORE image of what your data looks like before sorting
- the AFTER image of what your data looks like after sorting
- your desired result image
 
Upvote 0
Thank you for looking at this.

I hope the images show the problem.

The last image is the desired output.
 

Attachments

  • 2023-05-08 Mr Excel-02.jpg
    2023-05-08 Mr Excel-02.jpg
    76.8 KB · Views: 7
  • 2023-05-08 Mr Excel-03.jpg
    2023-05-08 Mr Excel-03.jpg
    174.9 KB · Views: 7
  • 2023-05-08 Mr Excel-04.jpg
    2023-05-08 Mr Excel-04.jpg
    76.2 KB · Views: 8
  • 2023-05-08 Mr Excel-05.jpg
    2023-05-08 Mr Excel-05.jpg
    73.6 KB · Views: 7
Upvote 0
A few things to check:

- Are those blank fields REALLY blank, or is there something actually in them?
For example, if G6 is one of the apparent blank cells, enter this formula in any unused blank cell anywhere on the sheet and tell us what it returns:
Excel Formula:
=LEN(G6)

- In your Last Name field, are there any spaces or characters at the beginning of the string BEFORE the last name like "Lange"?
 
Upvote 0
I checked the fields for spaces before and after the entry and found none.

I inserted the formula and the result is 0.

Notice that my initials, JL, appear to the right of "Lange". I do not know what that means.
 

Attachments

  • 2023-05-08 Mr Excel-06.jpg
    2023-05-08 Mr Excel-06.jpg
    126.9 KB · Views: 5
Upvote 0
Just to double-check, you are doing this in Excel, right? Not some other program?

And you are limiting your sort just to columns G, H, and I, right?

Why do you need a Custom Sort, instead of just using the basic built-in Sort feature?

If I try to recreate it, this is what I have:

Initial data:
1683571564360.png


Basic sort rules:
1683571611174.png


Results:
1683571676955.png
 
Upvote 0
I am using Excel. However, the file is on OneDrive and the only option available is Custom Sort.

My goal is to write a VBA macro to perform the sort. Can you help with this? Thank you.

Joe
 

Attachments

  • 2023-05-08 Mr Excel-07.jpg
    2023-05-08 Mr Excel-07.jpg
    49.8 KB · Views: 2
Upvote 0
I don't believe you can use Excel VBA on OneDrive.
Files in OneDrive can contain macros/VBA, but you cannot run them unless you download the file to a local drive.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,103
Messages
6,123,105
Members
449,096
Latest member
provoking

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