Can I include blank cells in sort?

ekinzie

New Member
Joined
Jan 25, 2005
Messages
5
I have a simple spreadsheet with dates in column B & E. I have two VB scripts attached to buttons that will sort the data in either of those two columns.

Any empty dates in column E would indicate a problem. If I run the script to sort by this column, I would like any cell with no data to be brought to the top in no particular order. Any other solution would work so long as it would bring attention to these blank fields. Perhaps even another script to check for empty cells in column E? I don't know much about VB scripts and got this far by the help of others on this site so thanks for your help!

Heres the script:

Private Sub CommandButton2_Click()
On Error Resume Next
Application.EnableEvents = False
Me.UsedRange.Sort _
Key1:=[B2], Order1:=xlAscending, header:=xlYes, Orientation:=xlSortColumns
Application.EnableEvents = True
On Error GoTo 0
End Sub

Private Sub CommandButton1_Click()
On Error Resume Next
Application.EnableEvents = False
Me.UsedRange.Sort _
Key1:=[E2], Order1:=xlAscending, header:=xlYes, Orientation:=xlSortColumns
Application.EnableEvents = True
On Error GoTo 0
End Sub

And heres what we're looking at:

trackingspreadsheet.jpg


Any ideas would be greatly appreciated.
EK
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I think you may want to see my answer to a similar request at:
http://www.mrexcel.com/board2/viewtopic.php?t=127059

Another way: Highlight A1, click on Format, conditional Formating..., change the slot "Condition 1", "Formula Is" and write, in the slot to the right,
=COUNTBLANK(E1:E1), then click on Format there, and select the Patterns tab. Select a color, say red, then click on OK. Now, click on the Format Painter (the little yellow brush icon in the Standard Toolbar), then click on A2:E100. Now, every place there is a blank date, you should see a red row!

Let us know if one of the above helps you solve your problem.
 
Upvote 0

Forum statistics

Threads
1,203,663
Messages
6,056,626
Members
444,879
Latest member
suzndush

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