Sort sheet alphabetically

Jakson

New Member
Joined
Sep 14, 2021
Messages
21
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I've got a data entry sheet on this workbook my agency uses for business purposes.

The data entry sheet consists of names, addresses, personal identifier numbers, and a type label.

Users are currently navigating to this sheet manually, reviewing the content of the sheet for completeness, manually entering new data, then manually sorting the sheet alphabetically on column A's last name values.

The data is duplicated four times so that there are 5 total copies of the same information, per person entered.

I'm familiar with inputboxes but I'm not sure how to go about sorting this sheet alphabetically through VBA.

Guidance is deeply appreciated
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

PeteWright

Board Regular
Joined
Dec 20, 2020
Messages
93
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
You could use this snippet I once wrote for sorting data with VBA.
Just edit it to suit your needs.


VBA Code:
Public Sub SortAZ()
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("data")
    With ws.Sort
        .SortFields.Clear
        .SortFields.Add Key:=ws.Range("A1"), Order:=xlAscending
        .SetRange ws.Range("A1:B999")
        .Header = xlYes
        .Apply
    End With
End Sub
 
Solution

Jakson

New Member
Joined
Sep 14, 2021
Messages
21
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
You could use this snippet I once wrote for sorting data with VBA.
Just edit it to suit your needs.


VBA Code:
Public Sub SortAZ()
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("data")
    With ws.Sort
        .SortFields.Clear
        .SortFields.Add Key:=ws.Range("A1"), Order:=xlAscending
        .SetRange ws.Range("A1:B999")
        .Header = xlYes
        .Apply
    End With
End Sub
Ooooo!!!

Awesome!!! Thank you so so much! I'll tweak it and mess with it as soon as I can! I just got buried in some work that came out from under our feet. WOOPs!

I bet this is it though! Thank you, @PeteWright !
 

Jakson

New Member
Joined
Sep 14, 2021
Messages
21
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
You could use this snippet I once wrote for sorting data with VBA.
Just edit it to suit your needs.


VBA Code:
Public Sub SortAZ()
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("data")
    With ws.Sort
        .SortFields.Clear
        .SortFields.Add Key:=ws.Range("A1"), Order:=xlAscending
        .SetRange ws.Range("A1:B999")
        .Header = xlYes
        .Apply
    End With
End Sub
Just wanted to come back and let you know @PeteWright , it works like a charm!

I've got some work to do to make the rest of my thingie do what I want but this little code snippet saved me a TON of time!
 

PeteWright

Board Regular
Joined
Dec 20, 2020
Messages
93
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
Just wanted to come back and let you know @PeteWright , it works like a charm!

I've got some work to do to make the rest of my thingie do what I want but this little code snippet saved me a TON of time!
Glad to hear that!
Let me know if you need anything else.

Kind regards
Pete
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,311
Messages
5,836,583
Members
430,438
Latest member
David Gr

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
Top